package com.dhcc.DRGsHosp.web.controller;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException;
import java.io.Writer;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.openkoala.koala.commons.InvokeResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.dhcc.DRGsHosp.facade.WordReportFacade;
import com.dhcc.DRGsHosp.facade.dto.ReportDTO;
import com.dhcc.DRGsHosp.infra.util.Arith;
import com.dhcc.DRGsHosp.infra.util.MonitorResultUtil;
import com.dhcc.DRGsHosp.pdfRender.utils.GetAbnormity;
import com.dhcc.DRGsHosp.pdfRender.utils.ResourceLoader;

import freemarker.template.Configuration;
import freemarker.template.Template;

/**
 * @Author:LiuHongjun
 * @Description: word版分析报告导出
 * @Date:2016年9月5日 下午1:50:49
 * @version :2.3.0
 * @copyright:DHCC 2014-2016
 */
@Controller("drgsHospWebController44")
@RequestMapping("/WordReport")
public class WordReportController {
	@Autowired
	private WordReportFacade wordReportFacade;

	Map<String, Object> remap = new HashMap<String, Object>();
	Map<String, Object> paramMap = new HashMap<String, Object>();// 存放条件
	/**
	 * @methodname :getBenchmarkYear
	 * @Description :获取标杆年份
	 * @author:LiuHongjun
	 * @return InvokeResult
	 * @date :2016年12月30日
	 */
	@ResponseBody
	@RequestMapping(value = "/getBenchmarkYear")
	public InvokeResult getBenchmarkYear() {		
		List<Object[]> asyearlist = wordReportFacade.getBenchmarkYear();
		return InvokeResult.success(asyearlist);	
	}
	/**
	 * @methodname :saveImg
	 * @Description : 保存图片信息
	 * @author:LiuHongjun
	 * @return InvokeResult
	 * @date :2016年9月5日
	 */
	@ResponseBody
	@RequestMapping(value = "/saveImg")
	public InvokeResult saveImg(@RequestParam String imgData, @RequestParam String imgName) {
		/**
		 * 生成图片部分
		 */
		try {
			String img = imgData.split(",")[1]; // 逗号分隔，逗号后面是base64图片编码
			remap.put(imgName, img);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return InvokeResult.success();
	}

	/**
	 * @methodname :findReportInfo
	 * @description : 获取分析报告基本信息
	 * @param :
	 * @author :liuhongjun
	 * @return :
	 * @date :2016年7月21日
	 */
	@ResponseBody
	@RequestMapping("/findReportInfo")
	public InvokeResult findReportInfo(ReportDTO dto) {
		DecimalFormat df = new DecimalFormat("0.00");
		DecimalFormat money = new DecimalFormat("#,###");
		DecimalFormat moneydb = new DecimalFormat("#,##0.00");
		String errMsg="";
		remap = new HashMap<String, Object>();
		paramMap = new HashMap<String, Object>();// 存放条件
		Map<String, List<Map<String, Object>>>  abnormalMap = new HashMap<String, List<Map<String, Object>>>();
		int isAbno=dto.getIsAbno();
		GetAbnormity abnorm = new GetAbnormity();// 定义抛出异常类
		// 判断有没有数据
		int dataIsNull = wordReportFacade.findDataIsNull(dto.getDateFrom(), dto.getDateTo());
		if (dataIsNull != 0) {
			List<Object[]> drgsList = wordReportFacade.findNewDrgs(dto.getDateFrom(), dto.getDateTo(), dto.getBenchmarkYear());
			if (!drgsList.isEmpty()) {
				Map<String, Object> nmap = new HashMap<String, Object>();
				nmap.put("newdrgs", 1);
				nmap.put("drgsList", drgsList);
				return InvokeResult.success(nmap);
			} else {
				try {
					String dateFrom = dto.getDateFrom();// 开始时间
					String dateTo = dto.getDateTo();// 结束时间
					String benchmarkYear = dto.getBenchmarkYear();// 标杆
					String analysisyear = dateFrom.substring(0, 4);// 分析的年份
					String startMonth = Integer.valueOf(dateFrom.substring(5, 7)) + "";// 分析开始月
					String endMonth = Integer.valueOf(dateTo.substring(5, 7)) + ""; // 分析结束月
				//	String hospRealBedNum = dto.getHospRealBedNum();// 实际开放总床日数
					String hospbulidyear = dto.getHospBuildYear();// 医院创建时间
					String dephospname=dto.getDephospname();//重点科室
					
					
					
					// 获取医院名称
					Properties pro = new Properties();
					InputStream inputStream=null;
					try {
						inputStream=WordReportController.class.getClassLoader().getResourceAsStream("/system.properties");
						pro.load(new InputStreamReader(inputStream, "UTF-8"));
					} catch (UnsupportedEncodingException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					} catch (IOException e) {
						e.printStackTrace();
						errMsg+=e.getMessage();
						remap.put("errMsg", errMsg);
					}finally {
						if(inputStream!=null) {
							inputStream.close();
						}
					}
					Calendar cal = Calendar.getInstance();// 使用日历类
					String year = cal.get(Calendar.YEAR) + "";// 得到年
					String month = (cal.get(Calendar.MONTH) + 1) + "";// 得到月，因为从0开始的，所以要加1
					paramMap.put("reportDateFrom", dateFrom);
					paramMap.put("reportDateTo", dateTo);
					paramMap.put("benchmarkYear", benchmarkYear);
					paramMap.put("dephospname", dephospname);
				

					remap.put("dephospname", dephospname);
				
					remap.put("startMonth", startMonth);
					remap.put("endMonth", endMonth);
					remap.put("hospname", dto.getHospName());
					remap.put("buildyear", hospbulidyear);
					remap.put("createyear", year);
					remap.put("createmonth", month);
					remap.put("hospbedcnt", dto.getHospBedNum());
					remap.put("hosprealbedcnt", dto.getHospRealBedNum());
					remap.put("hospdoctorcnt", dto.getHospDocNum());
					remap.put("hospcasecnt", dto.getHospCaseNum());
					remap.put("hospbeddayscnt",dto.getHospBedDaysNum());
					remap.put("hosprealbedncnt", dto.getHospRealBedNum());
					remap.put("hosplevel", dto.getHospLevel());
					// 获取科室数量
					int hospdepcnt = wordReportFacade.findDepCount();
					remap.put("hospdepcnt", hospdepcnt);

					// 获取出院病历术，大于60.入组数， 入组率
					Object[] hospBaseQuotaStOne = wordReportFacade.findSimpHospBaseQuota(paramMap);
					if (hospBaseQuotaStOne.length > 0) {
						remap.put("hospoutcasecnt", hospBaseQuotaStOne[0] == null ? "0": hospBaseQuotaStOne[0].toString());// 出院病例数
						remap.put("ingroupcasecnt",hospBaseQuotaStOne[1] == null ? "0" : hospBaseQuotaStOne[1].toString());// 入组数
						remap.put("over60casecnt", hospBaseQuotaStOne[2] == null ? "0" : hospBaseQuotaStOne[2].toString());// 大于60
						remap.put("ingroupratio", hospBaseQuotaStOne[3] == null ? 0 : hospBaseQuotaStOne[3]);// 入组率
						remap.put("notingroupcasecnt", hospBaseQuotaStOne[4] == null ? "0": hospBaseQuotaStOne[4].toString());// 未入组
					} else {
						remap.put("hospoutcasecnt", 0);// 出院病例数
						remap.put("ingroupcasecnt", 0);// 入组数
						remap.put("over60casecnt", 0);// 大于60
						remap.put("ingroupratio", 0);// 入组率
						remap.put("notingroupcasecnt", 0);// 未入组
					}
					// 获取本院使用的分组器
					String drgVer = wordReportFacade.getDRGversion(paramMap);
					StringBuffer drgVers = new StringBuffer();
					if (!"".equals(drgVer)) {
						Pattern p = Pattern.compile("[0-9]");
						Matcher ver = p.matcher(drgVer);
						while (ver.find()) {
							drgVers.append(ver.group());
						}
					}
					String drgVersion = drgVers.toString();
					remap.put("drgversion", drgVersion);
					remap.put("analysisyear", analysisyear);
					// 从配置文件里读取表格中的对比指标
					String regularStandard = pro.getProperty( "regularStandard");// 获取常规指标
					String staffStandard = pro.getProperty("staffStandard");// 获取参评指标
					if (!"".equals(regularStandard) && !"".equals(staffStandard)) {
						String[] regularStandardArray = regularStandard.split(",");
						for (int o = 0; o < regularStandardArray.length; o++) {
							remap.put("outcasecntst", regularStandardArray[0]==null?"0":regularStandardArray[0].toString());
							remap.put("avgfeest",  regularStandardArray[1]==null?0:regularStandardArray[1]);
							remap.put("avgdaysst",  regularStandardArray[2]==null?0:regularStandardArray[2]);
							remap.put("drugratiost",  regularStandardArray[3]==null?0:regularStandardArray[3]);
							remap.put("deadratiost",  regularStandardArray[4]==null?0:regularStandardArray[4]);
						}

						String[] staffStandardArray = staffStandard.split(",");
						for (int o = 0; o < staffStandardArray.length; o++) {
							remap.put("ingroupcasecntst",staffStandardArray[0]==null?"0":staffStandardArray[0].toString());
							remap.put("cmist", staffStandardArray[1]==null?0:staffStandardArray[1]);
							remap.put("drgcntst",staffStandardArray[2]==null?"0":staffStandardArray[2].toString());
							remap.put("totalweightst",staffStandardArray[3]==null?"0":staffStandardArray[3].toString());
							remap.put("begweightst",staffStandardArray[4]==null?0:staffStandardArray[4]);
							remap.put("timefeest", staffStandardArray[5]==null?0:staffStandardArray[5]);
							remap.put("efffeest", staffStandardArray[6]==null?0:staffStandardArray[6]);
							remap.put("risk1rationst", staffStandardArray[7]==null?0:staffStandardArray[7]);
						}
					}

					// 表格二中出院病例数，次均费用，药占比等
					Object[] hospBaseTable2StOne = wordReportFacade.findSimpHospBaseTable2(paramMap);
					if (hospBaseTable2StOne.length > 0) {
						remap.put("hospavgfee", hospBaseTable2StOne[1] == null ? 0 : hospBaseTable2StOne[1]);
						remap.put("hospavgdays", hospBaseTable2StOne[2] == null ? 0 : hospBaseTable2StOne[2]);
						remap.put("hospdrugratio", hospBaseTable2StOne[3] == null ? 0 : hospBaseTable2StOne[3]);
						remap.put("hospdeadratio",hospBaseTable2StOne[4] == null ? 0 : hospBaseTable2StOne[4]);
					} else {
						remap.put("hospavgfee", "--");
						remap.put("hospavgdays", "--");
						remap.put("hospdrugratio", "--");
						remap.put("hospdeadratio", "--");
					}
					
					//表格三 抗菌药物使用人次占比（%）	抗菌药物费用占药品费用比例（%）抗菌药物费用占总费用比例（%）
					//(	治疗性使用抗菌药物病例占比（%）	预防性使用抗菌药物病例占比（%）) 没有这两项的数据
					List<Object[]> hospTable3 = wordReportFacade.hospTable3(paramMap);
					if(!hospTable3.isEmpty()){
						for(Object[] obj:hospTable3){
							remap.put("table3_1", obj[0] == null ? 0 :obj[0]);//抗菌药物使用人次占比（%）
							remap.put("table3_2", obj[2] == null ? 0 :obj[2]);//抗菌药物费用占药品费用比例（%）
							remap.put("table3_3", obj[1] == null ? 0 :obj[1]);//抗菌药物费用占总费用比例（%）
							remap.put("table3_4", "--");//治疗性使用抗菌药物病例占比（%）
							remap.put("table3_5", "--");//预防性使用抗菌药物病例占比（%）
						}	
					}else{
						remap.put("table3_1", "--");//抗菌药物使用人次占比（%）
						remap.put("table3_2", "--");//抗菌药物费用占药品费用比例（%）
						remap.put("table3_3", "--");//抗菌药物费用占总费用比例（%）
						remap.put("table3_4", "--");//治疗性使用抗菌药物病例占比（%）
						remap.put("table3_5", "--");//预防性使用抗菌药物病例占比（%）
					}
					
					
						
					//表格三标杆值
					remap.put("biaogan3_1", "--");
					remap.put("biaogan3_2",  "--");
					remap.put("biaogan3_3",  "--");
					remap.put("biaogan3_4",  "--");
					remap.put("biaogan3_5",  "--");
					//表格四 院内感染率（%）	感染病例治疗性抗菌药物使用占比（%）
					//数据库中没数据
					List<Object[]> hospTable4 = wordReportFacade.hospTable4(paramMap);
					if(!hospTable4.isEmpty()){
						for(Object[] obj:hospTable4){
						remap.put("table4_1", obj[0]==null?0:obj[0]);//院内感染率（%）
						remap.put("table4_2", "--");//感染病例治疗性抗菌药物使用占比（%）(数据库中没相应字段)
						remap.put("table5_1", obj[1]==null?0:obj[1]);//临床路径入径率（%）
						}					
					}else{
						remap.put("table4_1", "--");//院内感染率（%）
						remap.put("table4_2", "--");//感染病例治疗性抗菌药物使用占比（%）(数据库中没相应字段)
						remap.put("table5_1", "--");//临床路径入径率（%）
					}
					//表格四标杆值
					remap.put("biaogan4_1",  "--");
					remap.put("biaogan4_2",  "--");
					//表格五 临床路径入径率（%）	路径变异率（%）	变异与非变异病例数比值
					//没有数据
					
						//remap.put("table5_1", "--");//临床路径入径率（%）
						remap.put("table5_2", "--");//路径变异率（%）(数据库中没相应字段)
						remap.put("table5_3", "--");//变异与非变异病例数比值（%）(数据库中没相应字段)
					//表格五标杆值
						remap.put("biaogan5_1",  "--");
						remap.put("biaogan5_2",  "--");
						remap.put("biaogan5_3",  "--");
					
					
					
					// 获取cmi，时间消耗指数，费用消耗指数，drg组数,总权重
					Object[] hospobj4 = wordReportFacade.findSimpHospBaseTable4(paramMap);
					remap.put("hospdrgcnt", hospobj4[0]==null?0:hospobj4[0]);
					remap.put("hospcmi", hospobj4[1]==null?0:hospobj4[1]);
					remap.put("hosptotalweight",  hospobj4[2]==null?0:hospobj4[2]);
					remap.put("hospingroupcnt",  hospobj4[3]==null?0:hospobj4[3]);
					remap.put("hospeffee",  hospobj4[4]==null?0:hospobj4[4]);
					remap.put("hosptimefee",  hospobj4[5]==null?0:hospobj4[5]);
					remap.put("deadrisk1ratio",  hospobj4[6]==null?0:hospobj4[6]);
					int yearDays = 0;
					if (Integer.valueOf(analysisyear) % 4 == 0 && Integer.valueOf(analysisyear) % 100 != 0 || Integer.valueOf(analysisyear) % 400 == 0) {
						yearDays = 366;
					} else {
						yearDays = 365;
					}
					double bedWeight=0;
					if(dto.getHospBedNum().equals("1")){
						remap.put("bedWeight", "--");
					}else{
						 double vtemp = MonitorResultUtil.objectToDouble(dto.getHospBedNum());
						 bedWeight =  vtemp!=0?(MonitorResultUtil.objectToDouble(remap.get("hosptotalweight")) / MonitorResultUtil.objectToDouble(dto.getHospBedNum())):0;
						 remap.put("bedWeight", bedWeight);
					}
				
					
					// ######################第二章开始######################################
					// 获取手术病例
					String caseOperCount = wordReportFacade.findHospCaseOperationCount(paramMap);
					remap.put("caseOperCount",caseOperCount);
					double operRation = Arith.div(MonitorResultUtil.objectToDouble(caseOperCount), MonitorResultUtil.objectToDouble(remap.get("hospoutcasecnt")), 4) * 100;
					//手术占比
					remap.put("operRation", operRation);

					// 获取手术级别
					List<Object[]> oplevelList = wordReportFacade.findOperCaseByLvel(paramMap);
					String mostlevelname = "--";
					int level1 = 0;
					int level2 = 0;
					int level3 = 0;
					int level4 = 0;
					int leveloth = 0;
					int mostlevelcnt = 0;
					if (oplevelList.size() > 0) {
						for (int i = 0; i < oplevelList.size(); i++) {
							Object[] obj = oplevelList.get(i);
							String level = obj[0] == null ? "--" : obj[0].toString().trim();
							int levelcnt = obj[1] == null ? 0 : MonitorResultUtil.objectToDouble(obj[1]).intValue();
							if (i == 0) {
								if (level.equals("1")) {
									level1 = levelcnt;
									mostlevelcnt = levelcnt;
									mostlevelname = "一级";
								} else if (level.equals("2")) {
									level2 = levelcnt;
									mostlevelcnt = levelcnt;
									mostlevelname = "二级";
								} else if (level.equals("3")) {
									level3 = levelcnt;
									mostlevelcnt = levelcnt;
									mostlevelname = "三级";
								} else if (level.equals("4")) {
									level4 = levelcnt;
									mostlevelcnt = levelcnt;
									mostlevelname = "四级";
								} else {
									leveloth = levelcnt;
									mostlevelcnt = levelcnt;
									mostlevelname = level;
								}
							} else {
								if (level.equals("1")) {
									level1 = levelcnt;
								} else if (level.equals("2")) {
									level2 = levelcnt;
								} else if (level.equals("3")) {
									level3 = levelcnt;
								} else if (level.equals("4")) {
									level4 = levelcnt;
								} else {
									leveloth = levelcnt;
								}
							}
						}
					}
					remap.put("mostlevelname", mostlevelname);
					remap.put("mostlevelratio", imputedRatio(MonitorResultUtil.objectToDouble(mostlevelcnt),MonitorResultUtil.objectToDouble(caseOperCount)));
					remap.put("level1",level1);
					remap.put("level2", level2);
					remap.put("level3", level3);
					remap.put("level4", level4);
					remap.put("leveloth", leveloth);
					// 表格6数据 
					List<Map<String, Object>> operLevelList = wordReportFacade.findOperLevelInfo(paramMap);
					remap.put("operLevelList", operLevelList);

					// 获取主要手术（根据手术编码分组）
					List<Object[]> mainOperListStepTwo = wordReportFacade.findMainOpeList(paramMap);
					StringBuilder sqlstr = new StringBuilder();
					if (mainOperListStepTwo.size() > 0) {
						// 获取主要手术种类数
						int mainoperkindcnt = mainOperListStepTwo.size();
						remap.put("mainoperkindcnt",mainoperkindcnt);
						int top20mainopercnt = 0;
						int totalopercnt=0;
						sqlstr.append("( \n");
						for (int i = 0; i < mainoperkindcnt; i++) {
							Object[] obj = mainOperListStepTwo.get(i);
							if (i < 20) {
								// 计算本院前20的手术数量
								top20mainopercnt = top20mainopercnt + MonitorResultUtil.objectToDouble((obj[1] == null ? 0 : obj[1]) + "").intValue();
								// 拼接手术频次前二十的手术编码
								sqlstr.append(" '" + obj[0] + "', \n");
							}
							totalopercnt+=MonitorResultUtil.objectToDouble((obj[1] == null ? 0 : obj[1]) + "").intValue();
						}
						sqlstr.append(" )\n");
						remap.put("top20mainopercnt", top20mainopercnt);
						remap.put("mainopertop20ratio",imputedRatio(MonitorResultUtil.objectToDouble(top20mainopercnt),MonitorResultUtil.objectToDouble(totalopercnt)));
					} else {
						remap.put("mainoperkindcnt", 0);
						remap.put("mainopertop20ratio", 0);
					}
					
					
					String sqlT = sqlstr.toString();
					int q = sqlT.lastIndexOf(",");
					StringBuffer buffero = new StringBuffer(sqlT);
					sqlT = buffero.replace(q, q + 1, "").toString();
					List<Object[]> operTop20ByLevelList = wordReportFacade.findTop20ByLevelList(paramMap, sqlT);
					List<Map<String, Object>> mainOperTop20List = new ArrayList<Map<String, Object>>();
					for (int i = 0; i < operTop20ByLevelList.size(); i++) {
						Map<String, Object> map = new HashMap<String, Object>();
						Object[] obj = operTop20ByLevelList.get(i);
						String obj0 = String.valueOf(obj[0] == null ? "0" : obj[0].toString().trim());
						if ("1".equals(obj0)) {
							map.put("level", "一级");
						} else if ("2".equals(obj0)) {
							map.put("level", "二级");
						} else if ("3".equals(obj0)) {
							map.put("level", "三级");
						} else if ("4".equals(obj0)) {
							map.put("level", "四级");
						} else {
							map.put("level", "其他");
						}
						map.put("cnt", obj[1]);
						mainOperTop20List.add(map);
					}
					remap.put("mainOperTop20List", mainOperTop20List);
					// 各级手术前5手术编码，名称，频次，占本级手术的占比
					List<Object[]> mainOperLevelInfoList = wordReportFacade.findmainOperLevelInfo(paramMap);
					List<Map<String, Object>> mainOperLevel1InfoTop5List = new ArrayList<Map<String, Object>>();
					List<Map<String, Object>> mainOperLevel2InfoTop5List = new ArrayList<Map<String, Object>>();
					List<Map<String, Object>> mainOperLevel3InfoTop5List = new ArrayList<Map<String, Object>>();
					List<Map<String, Object>> mainOperLevel4InfoTop5List = new ArrayList<Map<String, Object>>();
					List<Map<String, Object>> mainOperLevelothInfoTop5List = new ArrayList<Map<String, Object>>();
					int totalle1 = 0, totalle2 = 0, totalle3 = 0, totalle4 = 0, totallenull = 0;
					if (mainOperLevelInfoList.size() > 0) {						
						for (int m = 0; m < mainOperLevelInfoList.size(); m++) {
							Object[] obj = mainOperLevelInfoList.get(m);
							String obj0 = (obj[0] == null ? 0 : obj[0]) + "";
							String  obj1= (obj[1] == null ? 0 : obj[1]) + "";
							if (obj0.equals("1")) {
								totalle1 = totalle1 + Integer.valueOf(obj1);
							} else if (obj0.equals("2")) {
								totalle2 = totalle2 + Integer.valueOf(obj1);
			

							} else if (obj0.equals("3")) {
								totalle3 = totalle3 + Integer.valueOf(obj1);
	
							} else if (obj0.equals("4")) {
								totalle4 = totalle4 + Integer.valueOf(obj1);

							} else {
								totallenull = totallenull + Integer.valueOf(obj1);
							}
						}
					}
					int le1 = 1, le2 = 1, le3 = 1, le4 = 1, lenull = 1;					
					List<Object[]> mainOperLevel1List = wordReportFacade.findmainOperByLevelInfo(paramMap,"1");	
					if(!mainOperLevel1List.isEmpty()){
						for(Object[] obj:mainOperLevel1List){
							Map<String, Object> map = new HashMap<String, Object>();
							if (le1 < 6) {
								map.put("order", le1);
								map.put("level", "一级");
								map.put("opercode", obj[0]==null?"--": obj[0]);
								map.put("operation",  obj[1]==null?"--": obj[1]);
								map.put("opercnt", obj[2] ==null?0: obj[2]);
								map.put("operRatio",imputedRatio(MonitorResultUtil.objectToDouble((obj[2] == null ? 0 : obj[2]) + ""),MonitorResultUtil.objectToDouble(totalle1)));
								mainOperLevel1InfoTop5List.add(map);
								le1++;
							}
						}	
					}
					remap.put("mainOperLevel1InfoTop5List", mainOperLevel1InfoTop5List);
					
					List<Object[]> mainOperLevel2List = wordReportFacade.findmainOperByLevelInfo(paramMap,"2");	
					if(!mainOperLevel2List.isEmpty()){
						for(Object[] obj:mainOperLevel2List){
							Map<String, Object> map = new HashMap<String, Object>();
							if (le2 < 6) {
								map.put("order", le1);
								map.put("level", "二级");
								map.put("opercode", obj[0]==null?"--": obj[0]);
								map.put("operation",  obj[1]==null?"--": obj[1]);
								map.put("opercnt", obj[2] ==null?0: obj[2]);
								map.put("operRatio",imputedRatio(MonitorResultUtil.objectToDouble((obj[2] == null ? 0 : obj[2]) + ""),MonitorResultUtil.objectToDouble(totalle2)));
								mainOperLevel2InfoTop5List.add(map);
								le2++;
							}
						}	
					}
					remap.put("mainOperLevel2InfoTop5List", mainOperLevel2InfoTop5List);
					
					List<Object[]> mainOperLevel3List = wordReportFacade.findmainOperByLevelInfo(paramMap,"3");	
					if(!mainOperLevel3List.isEmpty()){
						for(Object[] obj:mainOperLevel3List){
							Map<String, Object> map = new HashMap<String, Object>();
							if (le3 < 6) {
								map.put("order", le1);
								map.put("level", "三级");
								map.put("opercode", obj[0]==null?"--": obj[0]);
								map.put("operation",  obj[1]==null?"--": obj[1]);
								map.put("opercnt", obj[2] ==null?0: obj[2]);
								map.put("operRatio",imputedRatio(MonitorResultUtil.objectToDouble((obj[2] == null ? 0 : obj[2]) + ""),MonitorResultUtil.objectToDouble(totalle3)));
								mainOperLevel3InfoTop5List.add(map);
								le3++;
							}
						}	
					}
					remap.put("mainOperLevel3InfoTop5List", mainOperLevel3InfoTop5List);
					
					List<Object[]> mainOperLevel4List = wordReportFacade.findmainOperByLevelInfo(paramMap,"4");	
					if(!mainOperLevel4List.isEmpty()){
						for(Object[] obj:mainOperLevel4List){
							Map<String, Object> map = new HashMap<String, Object>();
							if (le4 < 6) {
								map.put("order", le1);
								map.put("level", "四级");
								map.put("opercode", obj[0]==null?"--": obj[0]);
								map.put("operation",  obj[1]==null?"--": obj[1]);
								map.put("opercnt", obj[2] ==null?0: obj[2]);
								map.put("operRatio",imputedRatio(MonitorResultUtil.objectToDouble((obj[2] == null ? 0 : obj[2]) + ""),MonitorResultUtil.objectToDouble(totalle4)));
								mainOperLevel4InfoTop5List.add(map);
								le4++;
							}
						}	
					}
					remap.put("mainOperLevel4InfoTop5List", mainOperLevel4InfoTop5List);
					
					List<Object[]> mainOperLevelnullList = wordReportFacade.findmainOperByLevelInfo(paramMap,"null");	
					if(!mainOperLevelnullList.isEmpty()){
						for(Object[] obj:mainOperLevelnullList){
							Map<String, Object> map = new HashMap<String, Object>();
							if (lenull < 6) {
								map.put("order", le1);
								map.put("level", "其他");
								map.put("opercode", obj[0]==null?"--": obj[0]);
								map.put("operation",  obj[1]==null?"--": obj[1]);
								map.put("opercnt", obj[2] ==null?0: obj[2]);
								map.put("operRatio",imputedRatio(MonitorResultUtil.objectToDouble((obj[2] == null ? 0 : obj[2]) + ""),MonitorResultUtil.objectToDouble(totallenull)));
								mainOperLevelothInfoTop5List.add(map);
								lenull++;
							}
						}	
					}
					remap.put("mainOperLevelothInfoTop5List", mainOperLevelothInfoTop5List);

					// 频次发生最高前五名手术操作的科室分布
					List<Map<String, Object>> top1OpercodedepMapList = new ArrayList<Map<String, Object>>();
					List<Map<String, Object>> top2OpercodedepMapList = new ArrayList<Map<String, Object>>();
					List<Map<String, Object>> top3OpercodedepMapList = new ArrayList<Map<String, Object>>();
					List<Map<String, Object>> top4OpercodedepMapList = new ArrayList<Map<String, Object>>();
					List<Map<String, Object>> top5OpercodedepMapList = new ArrayList<Map<String, Object>>();
					List<Object[]> top5opercode = wordReportFacade.findTop5OperCode(paramMap);
					if (top5opercode.size() > 0) {
						for (int i = 0; i < top5opercode.size(); i++) {
							Object[] obj = top5opercode.get(i);
							if (i == 0) {
								top1OpercodedepMapList = wordReportFacade.top5OpercodedepListByOperCode(paramMap, obj[0]);
							} else if (i == 1) {
								top2OpercodedepMapList = wordReportFacade.top5OpercodedepListByOperCode(paramMap, obj[0]);
							} else if (i == 2) {
								top3OpercodedepMapList = wordReportFacade.top5OpercodedepListByOperCode(paramMap, obj[0]);
							} else if (i == 3) {
								top4OpercodedepMapList = wordReportFacade.top5OpercodedepListByOperCode(paramMap, obj[0]);
							} else if (i == 4) {
								top5OpercodedepMapList = wordReportFacade.top5OpercodedepListByOperCode(paramMap, obj[0]);
							}
						}
					}
					remap.put("top1OpercodedepMapList", top1OpercodedepMapList);
					remap.put("top2OpercodedepMapList", top2OpercodedepMapList);
					remap.put("top3OpercodedepMapList", top3OpercodedepMapList);
					remap.put("top4OpercodedepMapList", top4OpercodedepMapList);
					remap.put("top5OpercodedepMapList", top5OpercodedepMapList);

					// ##############################第三章开始##################################################################
					// 获取DRG病组,内科组，外科组，操作组
					int outdrgcnt = 0;
					int indrgcnt = 0;
					int operdrgcnt = 0;
					int outcasecnt = 0;
					int incasecnt = 0;
					int opercasecnt = 0;
					List<Map<String, Object>> hospDRGsInfoStep3 = wordReportFacade.findHospDRGsInfo(paramMap);
					for (Map<String, Object> map : hospDRGsInfoStep3) {
						// 外科部分
						if (Pattern.matches("\\w[ABCDEFGHJ]\\w{2}", map.get("drgCode") + "")) {
							outdrgcnt++;
							outcasecnt = outcasecnt + wordReportFacade.findPersonCnt(paramMap, map.get("drgCode"));
						}
						// 操作部分
						if (Pattern.matches("\\w[KLMNPQ]\\w{2}", map.get("drgCode") + "")) {
							operdrgcnt++;
							opercasecnt = opercasecnt + wordReportFacade.findPersonCnt(paramMap, map.get("drgCode"));
						}
						// 内科部分
						if (Pattern.matches("\\w[RSTUVWXYZ]\\w{2}", map.get("drgCode") + "")) {
							indrgcnt++;
							incasecnt = incasecnt + wordReportFacade.findPersonCnt(paramMap, map.get("drgCode"));
						}
					}
					int totaldrgCnt = hospDRGsInfoStep3.size();

					remap.put("totaldrgcnt", totaldrgCnt);
					remap.put("outdrgcnt", outdrgcnt);
					remap.put("indrgcnt", indrgcnt);
					remap.put("operdrgcnt", operdrgcnt);
					remap.put("outcasecnt", outcasecnt);
					remap.put("incasecnt", incasecnt);
					remap.put("opercasecnt", opercasecnt);

					int DRGsType1Num = 0;
					int DRGsType3Num = 0;
					int DRGsType5Num = 0;
					int DRGsType7Num = 0;
					int DRGsType9Num = 0;

					int CaseType1Num = 0;
					int CaseType3Num = 0;
					int CaseType5Num = 0;
					int CaseType7Num = 0;
					int CaseType9Num = 0;
					for (Map<String, Object> map : hospDRGsInfoStep3) {
						// “1，2”表示伴重要合并症和伴随病
						if (Pattern.matches("\\w{3}1", map.get("drgCode") + "") || Pattern.matches("\\w{3}2", map.get("drgCode") + "")) {
							DRGsType1Num++;
							CaseType1Num = CaseType1Num + wordReportFacade.findPersonCnt(paramMap, map.get("drgCode"));
						}
						// “3,4”表示伴合并症和伴随病
						if (Pattern.matches("\\w{3}3", map.get("drgCode") + "") || Pattern.matches("\\w{3}4", map.get("drgCode") + "")) {
							DRGsType3Num++;
							CaseType3Num = CaseType3Num + wordReportFacade.findPersonCnt(paramMap, map.get("drgCode"));
						}
						// “5,6”表示不伴合并症和伴随
						if (Pattern.matches("\\w{3}5", map.get("drgCode") + "") || Pattern.matches("\\w{3}6", map.get("drgCode") + "")) {
							DRGsType5Num++;
							CaseType5Num = CaseType5Num + wordReportFacade.findPersonCnt(paramMap, map.get("drgCode"));
						}
						// “7”表示住院5天内死亡或转院
						if (Pattern.matches("\\w{3}7", map.get("drgCode") + "")) {
							DRGsType7Num++;
							CaseType7Num = CaseType7Num + wordReportFacade.findPersonCnt(paramMap, map.get("drgCode"));
						}

					}
					DRGsType9Num = hospDRGsInfoStep3.size() - DRGsType1Num - DRGsType3Num - DRGsType5Num - DRGsType7Num;
					remap.put("DRGsType1Num", DRGsType1Num);
					remap.put("DRGsType3Num", DRGsType3Num);
					remap.put("DRGsType5Num", DRGsType5Num);
					remap.put("DRGsType7Num", DRGsType7Num);
					remap.put("DRGsType9Num", DRGsType9Num);
					if (remap.get("ingroupcasecnt") != null) {
						CaseType9Num = MonitorResultUtil.objectToDouble(remap.get("ingroupcasecnt") + "").intValue() - CaseType1Num - CaseType3Num - CaseType5Num - CaseType7Num;
					} else {
						CaseType9Num = 0;
					}
					remap.put("CaseType1Num", CaseType1Num);
					remap.put("CaseType3Num", CaseType3Num);
					remap.put("CaseType5Num", CaseType5Num);
					remap.put("CaseType7Num", CaseType7Num);
					remap.put("CaseType9Num", CaseType9Num);

					// 获取各科室DRGs组数覆盖情况表格信息
					String depDRGsCntMostFirst = "--";// 覆盖DRGs组数最多的科室
					String depDRGsCntMostFirstCnt = "--";// 覆盖DRGs组数
					String depDRGsCntMostSecond = "--";// 覆盖DRGs组数2的科室
					String depDRGsCntMostSecondCnt = "--";// 覆盖DRGs2组数

					String depDRGsCntLeastFirst = "--";// 覆盖DRGs组数最少的科室
					String depDRGsCntLeastSecond = "--";// 覆盖DRGs组数2的科室
					String depDRGsCntLeastThirdly = "--";// 覆盖DRGs组数3的科室
					int depDrgCnt=0;
					List<Object[]> depDRGsList = wordReportFacade.findCapacityDepInfoByDRGsCountList(paramMap);
					if (!depDRGsList.isEmpty()) {
						int depByDcIndex = 0;
						for (Object[] depByDc : depDRGsList) {
							if (depByDcIndex == 0) {
								depDRGsCntMostFirst = depByDc[1] + "";
								depDRGsCntMostFirstCnt = "(" + depByDc[2] + "组)";
							} else if (depByDcIndex == 1) {
								depDRGsCntMostSecond = depByDc[1] + "";
								depDRGsCntMostSecondCnt = "(" + depByDc[2] + "组)";
							} else if (depByDcIndex == depDRGsList.size() - 1) {
								depDRGsCntLeastFirst = depByDc[1] + "";
							} else if (depByDcIndex == depDRGsList.size() - 2) {
								depDRGsCntLeastSecond = depByDc[1] + "";
							} else if (depByDcIndex == depDRGsList.size() - 3) {
								depDRGsCntLeastThirdly = depByDc[1] + "";
							}
							depDrgCnt=depDrgCnt + (depByDc[2]==null?0:MonitorResultUtil.objectToDouble(depByDc[2].toString()).intValue());
							depByDcIndex++;
						}
					}
					//科室的平均drg组数
					remap.put("depavg_drgcnt", Arith.div(Double.parseDouble(depDrgCnt + ""), Double.parseDouble(hospdepcnt + ""), 0));
					remap.put("depDRGsCntMostFirst", depDRGsCntMostFirst);
					remap.put("depDRGsCntMostFirstCnt", depDRGsCntMostFirstCnt);
					remap.put("depDRGsCntMostSecond", depDRGsCntMostSecond);
					remap.put("depDRGsCntMostSecondCnt", depDRGsCntMostSecondCnt);
					remap.put("depDRGsCntLeastFirst", depDRGsCntLeastFirst);
					remap.put("depDRGsCntLeastSecond", depDRGsCntLeastSecond);
					remap.put("depDRGsCntLeastThirdly", depDRGsCntLeastThirdly);
					// 表格 10 DRGs组数覆盖前五位和后五位的科室情况
					List<Map<String, Object>> depDRGsCntTop5Last5List = new ArrayList<Map<String, Object>>();
					// 获取各科室DRGs组数覆盖情况表格信息
					
					for (int i = 0; i < 5; i++) {
						Object[] depByDctop = depDRGsList.get(i);
						Object[] depByDclast = depDRGsList.get(depDRGsList.size() - (i + 1));
						Map<String, Object> map = new HashMap<String, Object>();
						map.put("ordertop", i + 1);
						map.put("orderlast", i + 1);
						map.put("deptop", depByDctop[1]+"");
						map.put("deplast", depByDclast[1]+"");
						map.put("drgcnttop", MonitorResultUtil.objectToDouble(depByDctop[2] == null ? "0" : depByDctop[2].toString()).intValue());
						map.put("drgcntlast", MonitorResultUtil.objectToDouble(depByDclast[2] == null ? "0" : depByDclast[2].toString()).intValue());
						depDRGsCntTop5Last5List.add(map);
					}
				remap.put("depDRGsCntTop5Last5List", depDRGsCntTop5Last5List);			
				// 获取CMI排名科室情况表格信息(表格 11 CMI值排名前五位和后五位的科室情况)
				List<Map<String, Object>> depCmiTop5Last5List = new ArrayList<Map<String, Object>>();
				int depCount4CMIGreaterThan1 = 0;// CMI大于1的科室数量
				int depCount4CMILessThan1 = 0;// CMI<=1的科室数量
				String depcmiMostFirst = "--";// 覆盖cmi最多的科室
				String depcmiMostFirstCnt = "--";// 覆盖cmi
				String depcmiMostSecond = "--";// 覆盖cmi2的科室
				String depcmiMostThirdly = "--";// 覆盖cmi2的科室
				
				String depcmiLeastFirst = "--";// 覆盖cmi最少的科室
				String depcmiLeastFirstCnt = "--";// 覆盖cmi最少的科室
				String depcmiLeastSecond = "--";// 覆盖cmi2的科室
				String depcmiLeastThirdly = "--";// 覆盖cmi3的科室
				
				List<Object[]> depTableInfoByCMIList = wordReportFacade.findCapacityDepInfoByCMIList(paramMap);
				if (!depTableInfoByCMIList.isEmpty()) {	
					double hospcmi=remap.get("hospcmi")==null?0:MonitorResultUtil.objectToDouble(remap.get("hospcmi")+"");
					for (Object[] depByCMI : depTableInfoByCMIList) {
						if (Double.parseDouble(depByCMI[2] == null ? "0" : depByCMI[2].toString()) > hospcmi) {
							depCount4CMIGreaterThan1 += 1;
						} else if (Double.parseDouble(depByCMI[2] == null ? "0" : depByCMI[2].toString()) <=hospcmi) {
							depCount4CMILessThan1 += 1;
						}
					}
					for (int i = 0; i < 5; i++) {
						Object[] depByDctop = depTableInfoByCMIList.get(i);
						Object[] depByDclast = depTableInfoByCMIList.get(depTableInfoByCMIList.size() - (i + 1));
						Map<String, Object> map = new HashMap<String, Object>();
						if(i==0){
							depcmiMostFirst=depByDctop[1]+"";
							depcmiMostFirstCnt=depByDctop[2] == null ? "0" : depByDctop[2].toString();
							depcmiLeastFirst=depByDclast[1]+"";
							depcmiLeastFirstCnt=depByDclast[2] == null ? "0" : depByDclast[2].toString();
						}else if (i==1){
							depcmiMostSecond=depByDctop[1]+"";
							depcmiLeastSecond=depByDclast[1]+"";
						}else if (i==2){
							depcmiMostThirdly=depByDctop[1]+"";
							depcmiLeastThirdly=depByDclast[1]+"";
						}
					
						map.put("ordertop", i + 1);
						map.put("orderlast", i + 1);
						map.put("deptop", depByDctop[1]+"");
						map.put("deplast", depByDclast[1]+"");
						map.put("cmitop", Double.parseDouble(depByDctop[2] == null ? "0" : depByDctop[2].toString()));
						map.put("cmilast", Double.parseDouble(depByDclast[2] == null ? "0" : depByDclast[2].toString()));
						depCmiTop5Last5List.add(map);
					}			
				}
				
				remap.put("depcmiMostFirst", depcmiMostFirst);
				remap.put("depcmiMostFirstCnt", depcmiMostFirstCnt);
				remap.put("depcmiMostSecond", depcmiMostSecond);
				remap.put("depcmiMostThirdly", depcmiMostThirdly);
				remap.put("depcmiLeastFirst", depcmiLeastFirst);
				remap.put("depcmiLeastFirstCnt", depcmiLeastFirstCnt);
				remap.put("depcmiLeastSecond", depcmiLeastSecond);
				remap.put("depcmiLeastThirdly", depcmiLeastThirdly);

				remap.put("depCmiTop5Last5List", depCmiTop5Last5List);					
				remap.put("depCmiThan1", depCount4CMIGreaterThan1);
				remap.put("depCmiThan1Ratio", imputedRatio(MonitorResultUtil.objectToDouble(depCount4CMIGreaterThan1+""),MonitorResultUtil.objectToDouble(hospdepcnt+"")));
				remap.put("depCmiLess1", depCount4CMILessThan1);	
				remap.put("depCmiLess1Ratio",  imputedRatio(MonitorResultUtil.objectToDouble(depCount4CMILessThan1+""),MonitorResultUtil.objectToDouble(hospdepcnt+"")));				
				
				//科室权重
				List<Object[]> depWeightList = wordReportFacade.findCapacityDepInfoByWeightList(paramMap);
				String depWeightMost="";
				Double depMostWeight=0.0;
				String depWeightSecond="";
				Double depSecondWeight=0.0;
				String depWeightLast="";
				Double depLastWeight=0.0;
				List<Map<String, Object>> depWeightPT5List = new ArrayList<Map<String, Object>>();
				if (!depWeightList.isEmpty()) {			
					int depByDcIndex = 0;
					for (Object[] depByDc : depWeightList) {
						if (depByDcIndex == 0) {
							depWeightMost=depByDc[1]+"";
							depMostWeight=MonitorResultUtil.objectToDouble(depByDc[2]==null?"0":depByDc[2]+"");
						} else if (depByDcIndex == 1) {
							depWeightSecond=depByDc[1]+"";
							depSecondWeight=MonitorResultUtil.objectToDouble(depByDc[2]==null?"0":depByDc[2]+"");
						} else if (depByDcIndex == depWeightList.size() - 1) {
							depWeightLast=depByDc[1]+"";
							depLastWeight=MonitorResultUtil.objectToDouble(depByDc[2]==null?"0":depByDc[2]+"");
						}
						depByDcIndex++;
					}

					for (int i = 0; i < 5; i++) {
						Object[] depByDctop = depWeightList.get(i);
						Object[] depByDclast = depWeightList.get(depWeightList.size() - (i + 1));
						Map<String, Object> map = new HashMap<String, Object>();
						map.put("ordertop", i + 1);
						map.put("orderlast", i + 1);
						map.put("deptop", depByDctop[1]+"");
						map.put("deplast", depByDclast[1]+"");
						map.put("weighttop", Double.parseDouble(depByDctop[2] == null ? "0" : depByDctop[2].toString()));
						map.put("weightlast", Double.parseDouble(depByDclast[2] == null ? "0" : depByDclast[2].toString()));
						depWeightPT5List.add(map);
					}
				}	

				remap.put("depWeightMost", depWeightMost);	
				remap.put("depMostWeight", "("+depMostWeight+")");	
				remap.put("depMostWeightRatio",  imputedRatio(depMostWeight,MonitorResultUtil.objectToDouble(remap.get("hosptotalweight")==null?"1":remap.get("hosptotalweight")+"")));		
				
				remap.put("depWeightSecond", depWeightSecond);	
				remap.put("depSecondWeight", "("+depSecondWeight+")");	
				remap.put("depSecondWeightRatio",  imputedRatio(depSecondWeight,MonitorResultUtil.objectToDouble(remap.get("hosptotalweight")==null?"1":remap.get("hosptotalweight")+"")));		
				
				remap.put("depWeightLast", depWeightLast);	
				remap.put("depLastWeight", "("+depLastWeight+")");	
				remap.put("depLastWeightRatio",  imputedRatio(depLastWeight,MonitorResultUtil.objectToDouble(remap.get("hosptotalweight")==null?"1":remap.get("hosptotalweight")+"")));					
				remap.put("depWeightPT5List", depWeightPT5List);	
				
				//科室cmi和权重
				int depCntone = 0;
				int depCnttwo = 0;
				int depCntthreey = 0;
				int depCntfour = 0;
				StringBuffer depCMIAndWeightQuadrantone = new StringBuffer();
				StringBuffer depCMIAndWeightQuadranttwo = new StringBuffer();
				StringBuffer depCMIAndWeightQuadrantthreey = new StringBuffer();
				StringBuffer depCMIAndWeightQuadrantfour = new StringBuffer();
				
				List<Map<String, Object>> depWeightAndCMIList = wordReportFacade.findDepWeightAndCMI(paramMap);
				abnormalMap = new HashMap<String, List<Map<String, Object>>>();
				List<Map<String, Object>> depnormalWeightAndCMIList = new ArrayList<Map<String, Object>>();
				//压入不正常的数据
				String depCWAbnormal="";
				if(isAbno==1){
					abnormalMap = abnorm.getAbnormalDataMap(depWeightAndCMIList, "weight", "cmi");//计算是否有异常数据
					List<Map<String, Object>> depAbnormalWeightAndCMIList = abnormalMap.get("abnorMapList");// 异常数据
					depnormalWeightAndCMIList = abnormalMap.get("norMapList");// 参与计算数据
					StringBuffer depCmiWeightAbnormal = new StringBuffer();				
					for (Map<String, Object> map : depAbnormalWeightAndCMIList) {
						Double weight = MonitorResultUtil.objectToDouble(String.valueOf(map.get("weight") == null ? 0 : map.get("weight")));
						Double cmi = MonitorResultUtil.objectToDouble(String.valueOf(map.get("cmi") == null ? 0 : map.get("cmi")));
						depCmiWeightAbnormal.append(map.get("depname") + "(" + cmi + "," + weight + ")、");
					}
					if (depCmiWeightAbnormal.lastIndexOf("、") > 0) {
						depCWAbnormal= depCmiWeightAbnormal.substring(0, depCmiWeightAbnormal.lastIndexOf("、"))+"";
						remap.put("depCWAbnormal",depCWAbnormal+"作为特异数据未显示在下图中。");
					}else{
						remap.put("depCWAbnormal"," ");
					}
				}else{
					depnormalWeightAndCMIList=depWeightAndCMIList;
					remap.put("depCWAbnormal",depCWAbnormal);
				}	
				Double depmiddleWeight=imputedMiddleWeight(depnormalWeightAndCMIList);
				Double depmiddleCmi=imputedMiddleCmi(depnormalWeightAndCMIList);
				for (Map<String, Object> map : depnormalWeightAndCMIList) {
					Double weight = MonitorResultUtil.objectToDouble(String.valueOf(map.get("weight") == null ? 0 : map.get("weight")));
					Double cmi = MonitorResultUtil.objectToDouble(String.valueOf(map.get("cmi") == null ? 0 : map.get("cmi")));
					if (weight > depmiddleWeight && cmi > depmiddleCmi) {
						depCntone++;
						depCMIAndWeightQuadrantone.append(map.get("depname") + "(" + cmi + "," + weight + ")、");
					} else if (weight > depmiddleWeight && cmi <= depmiddleCmi) {
						depCnttwo++;
						depCMIAndWeightQuadranttwo.append(map.get("depname") + "(" + cmi + "," + weight + ")、");
					} else if (weight <= depmiddleWeight && cmi <= depmiddleCmi) {
						depCntthreey++;
						depCMIAndWeightQuadrantthreey.append(map.get("depname") + "(" + cmi + "," + weight + ")、");
					} else if (weight <= depmiddleWeight && cmi > depmiddleCmi) {
						depCntfour++;
						depCMIAndWeightQuadrantfour.append(map.get("depname") + "(" + cmi + "," + weight + ")、");
					}
				}
				remap.put("depmiddleWeight", depmiddleWeight);
				remap.put("depmiddleCmi", depmiddleCmi);	
				remap.put("depCntone", depCntone);	
				remap.put("depCnttwo", depCnttwo);	
				remap.put("depCntthreey", depCntthreey);	
				remap.put("depCntfour", depCntfour);
				String	depCMIAndWeightQuadrantoneStr="--";
				String	depCMIAndWeightQuadranttwoStr="--";
				String	depCMIAndWeightQuadrantthreeyStr="--";
				String	depCMIAndWeightQuadrantfourStr="--";
				if (depCMIAndWeightQuadrantone.lastIndexOf("、") > 0) {
					depCMIAndWeightQuadrantoneStr=depCMIAndWeightQuadrantone.substring(0, depCMIAndWeightQuadrantone.lastIndexOf("、"))+"";
				}
				if (depCMIAndWeightQuadranttwo.lastIndexOf("、") > 0) {
					depCMIAndWeightQuadranttwoStr=depCMIAndWeightQuadranttwo.substring(0, depCMIAndWeightQuadranttwo.lastIndexOf("、"))+"";
				}
				if (depCMIAndWeightQuadrantthreey.lastIndexOf("、") > 0) {
					depCMIAndWeightQuadrantthreeyStr=depCMIAndWeightQuadrantthreey.substring(0, depCMIAndWeightQuadrantthreey.lastIndexOf("、"))+"";
				}
				if (depCMIAndWeightQuadrantfour.lastIndexOf("、") > 0) {
					depCMIAndWeightQuadrantfourStr=depCMIAndWeightQuadrantfour.substring(0, depCMIAndWeightQuadrantfour.lastIndexOf("、"))+"";
				}
				remap.put("depCMIAndWeightQuadrantone", depCMIAndWeightQuadrantoneStr);
				remap.put("depCMIAndWeightQuadranttwo", depCMIAndWeightQuadranttwoStr);
				remap.put("depCMIAndWeightQuadrantthreey", depCMIAndWeightQuadrantthreeyStr);
				remap.put("depCMIAndWeightQuadrantfour", depCMIAndWeightQuadrantfourStr);
				remap.put("depnormalWeightAndCMIList", depnormalWeightAndCMIList);
	
				// 获取科室时间费用消耗指数
				int depCount4FeeEffGreaterThan1 = 0;// 费用消耗指数大于1的科室数量
				int depCount4TimeEffGreaterThan1 = 0;// 时间消耗指数大于1的科室数量
				List<Object[]> efficiencyDepInfoList = wordReportFacade.findEfficiencyDepInfoList(paramMap);
				if (!efficiencyDepInfoList.isEmpty()) {				
					for (Object[] efficiencyDepInfo : efficiencyDepInfoList) {
						if (Double.parseDouble(efficiencyDepInfo[2] == null ? "0" : efficiencyDepInfo[2].toString()) > 1) {// 费用消耗指数大于1
							depCount4FeeEffGreaterThan1 += 1;
						}
						if (Double.parseDouble(efficiencyDepInfo[3] == null ? "0" : efficiencyDepInfo[3].toString()) > 1) {// 时间消耗指数大于1
							depCount4TimeEffGreaterThan1 += 1;
						}
					}
				}
				remap.put("depFeeThan1", depCount4FeeEffGreaterThan1);
				remap.put("depEffThan1", depCount4TimeEffGreaterThan1);
				remap.put("depFeeThan1Ratio",imputedRatio(MonitorResultUtil.objectToDouble(depCount4FeeEffGreaterThan1),MonitorResultUtil.objectToDouble(hospdepcnt)));
				remap.put("depEffThan1Ratio",imputedRatio(MonitorResultUtil.objectToDouble(depCount4TimeEffGreaterThan1),MonitorResultUtil.objectToDouble(hospdepcnt)));
			
				// 科室--费用消耗指数--时间消耗指数
				StringBuffer depFeeEffAndTimeEffQuadrant1 = new StringBuffer();
				StringBuffer depFeeEffAndTimeEffQuadrant2 = new StringBuffer();
				StringBuffer depFeeEffAndTimeEffQuadrant3 = new StringBuffer();
				StringBuffer depFeeEffAndTimeEffQuadrant4 = new StringBuffer();
				String depFeeET1Str="--";
				String depFeeET2Str="--";
				String depFeeET3Str="--";
				String depFeeET4Str="--";
				int depFT1=0;int depFT2=0;int depFT3=0;int depFT4=0;
				List<Map<String, Object>> depFeeAndTimeEffMapList = new ArrayList<Map<String, Object>>();
				StringBuffer depTimeFeeAbnormal = new StringBuffer();
				for (Object[] depInfo : efficiencyDepInfoList) {
					if(depInfo[0]==null || depInfo[1]==null) continue;
					Map<String, Object> map = new HashMap<String, Object>();
					map.put("depCode", depInfo[0].toString());
					map.put("depName", depInfo[1].toString());
					map.put("feeEff", Arith.round(Double.parseDouble(depInfo[2] == null ? "0" : depInfo[2].toString()), 2));
					map.put("timeEff", Arith.round(Double.parseDouble(depInfo[3] == null ? "0" : depInfo[3].toString()), 2));
					depFeeAndTimeEffMapList.add(map);
				}
				if(isAbno==1){
					// 检测时间费用消耗指数异常数据
					abnormalMap = new HashMap<String, List<Map<String, Object>>>();
					abnormalMap = abnorm.getAbnormalDataMap(depFeeAndTimeEffMapList, "feeEff", "timeEff");
					List<Map<String, Object>> depAbnormalTimeFeeList = abnormalMap.get("abnorMapList");// 异常数据
					List<Map<String, Object>> depnormalTimeFeeList = abnormalMap.get("norMapList");// 参与计算数据
					depFeeAndTimeEffMapList=depnormalTimeFeeList;
					for (Map<String, Object> map : depAbnormalTimeFeeList) {
						Double feeEff = MonitorResultUtil.objectToDouble(String.valueOf(map.get("feeEff") == null ? 0 : map.get("feeEff")));
						Double timeEff = MonitorResultUtil.objectToDouble(String.valueOf(map.get("timeEff") == null ? 0 : map.get("timeEff")));
						depTimeFeeAbnormal.append(map.get("depName") + "(" + timeEff + "," + feeEff + ")、");
					}
					if (depTimeFeeAbnormal.lastIndexOf("、") > 0) {
						depCWAbnormal= depTimeFeeAbnormal.substring(0, depTimeFeeAbnormal.lastIndexOf("、"))+"";
						remap.put("depTimeFeeAbnormal",depCWAbnormal+"作为特异数据未显示在下图中。");
					}else{
						remap.put("depTimeFeeAbnormal",depCWAbnormal);
					}
				}else{
					remap.put("depTimeFeeAbnormal",depCWAbnormal);
				}
				double depModdleFee=imputedMiddleFee(depFeeAndTimeEffMapList);
				double depModdleTime=imputedMiddleTime(depFeeAndTimeEffMapList);
				for (Map<String, Object> map : depFeeAndTimeEffMapList) {
					Double fee = MonitorResultUtil.objectToDouble(String.valueOf(map.get("feeEff") == null ? 0 : map.get("feeEff")));
					Double time = MonitorResultUtil.objectToDouble(String.valueOf(map.get("timeEff") == null ? 0 : map.get("timeEff")));
					if (fee >1 && time > 1) {
						depFT1++;
						depFeeEffAndTimeEffQuadrant1.append(map.get("depName") + "(" + time + "," + fee + ")、");
					} else if (fee > 1 && time <= 1) {
						depFT2++;
						depFeeEffAndTimeEffQuadrant2.append(map.get("depName") + "(" + time + "," + fee + ")、");
					} else if (fee <= 1 && time <= 1) {
						depFT3++;
						depFeeEffAndTimeEffQuadrant3.append(map.get("depName") + "(" + time + "," + fee + ")、");
					} else if (fee <=1 && time > 1) {
						depFT4++;
						depFeeEffAndTimeEffQuadrant4.append(map.get("depName") + "(" + time + "," + fee + ")、");
					}

				}
				remap.put("depModdleFee", depModdleFee);
				remap.put("depModdleTime", depModdleTime);
				remap.put("depFT1", depFT1);
				remap.put("depFT2", depFT2);
				remap.put("depFT3", depFT3);
				remap.put("depFT4", depFT4);
				if (depFeeEffAndTimeEffQuadrant1.lastIndexOf("、") > 0) {
					depFeeET1Str=depFeeEffAndTimeEffQuadrant1.substring(0, depFeeEffAndTimeEffQuadrant1.lastIndexOf("、"));
				}
				if (depFeeEffAndTimeEffQuadrant2.lastIndexOf("、") > 0) {
					depFeeET2Str=depFeeEffAndTimeEffQuadrant2.substring(0, depFeeEffAndTimeEffQuadrant2.lastIndexOf("、"));
				}
				if (depFeeEffAndTimeEffQuadrant3.lastIndexOf("、") > 0) {
					depFeeET3Str=depFeeEffAndTimeEffQuadrant3.substring(0, depFeeEffAndTimeEffQuadrant3.lastIndexOf("、"));
				}
				if (depFeeEffAndTimeEffQuadrant4.lastIndexOf("、") > 0) {
					depFeeET4Str=depFeeEffAndTimeEffQuadrant4.substring(0, depFeeEffAndTimeEffQuadrant4.lastIndexOf("、"));
				}
				remap.put("depEeeET1", depFeeET1Str);
				remap.put("depEeeET2", depFeeET2Str);
				remap.put("depEeeET3", depFeeET3Str);
				remap.put("depEeeET4", depFeeET4Str);
				remap.put("depFeeAndTimeEffMapList", depFeeAndTimeEffMapList);
				
				// 获取全院中低风险死亡率
				String hospCaseRisk1DeadRatio = wordReportFacade.findHospCaseRisk1Ratio(paramMap);
				remap.put("hospCaseRisk1DeadRatio", Double.parseDouble(hospCaseRisk1DeadRatio==null?"0":hospCaseRisk1DeadRatio));
		
				// 获取低风险死亡情况科室信息
				List<Object[]> depDeaRisk1List = wordReportFacade.findQualityDepTableByRisk1List(paramMap);
				String depDeaRisk1Most="";
				int depDeaRisk1MostCnt=0;
				String depDeaRisk1Second="";
				int depDeaRisk1SecondCnt=0;
				//int depDeaRisk1Cnt=0;
				List<Map<String, Object>> depDeaRisk1MapList = new ArrayList<Map<String, Object>>();
				if (!depDeaRisk1List.isEmpty()) {
					int index = 0;
					for (Object[] obj : depDeaRisk1List) {
						Map<String, Object> map = new HashMap<String, Object>();
						if (index == 0) {
							depDeaRisk1Most=obj[0] + "";
							depDeaRisk1MostCnt=MonitorResultUtil.objectToDouble(obj[2]==null?"0":obj[2]+"").intValue();
						} else if (index == 1) {
							depDeaRisk1Second=obj[0] + "";
							//depDeaRisk1SecondCnt=MonitorResultUtil.objectToDouble(obj[2]==null?"0":obj[2]+"").intValue();
						}
						map.put("order",index+1);
						map.put("dep", obj[0]+"");
						map.put("incnt", obj[1]+"");
						map.put("deadcnt", obj[2]+"");
						map.put("deadRatio", df.format(obj[3])+"");
						depDeaRisk1MapList.add(map);
						//总死亡例数
						//depDeaRisk1Cnt+=MonitorResultUtil.objectToDouble(obj[2]==null?"0":obj[2]+"").intValue();
						index++;
					}
				} 
				remap.put("depDeaRisk1Most", depDeaRisk1Most);
				remap.put("depDeaRisk1MostCnt","("+ depDeaRisk1MostCnt+"例)");
				remap.put("depDeaRisk1Second", depDeaRisk1Second);
				remap.put("depDeaRisk1SecondCnt","("+ depDeaRisk1SecondCnt+"例)");
				remap.put("depDeaRisk1MapList", depDeaRisk1MapList);
				//remap.put("depDeaRisk1Cnt", depDeaRisk1Cnt);
				
				// 获取全院中低风险死亡率
				String hospCaseRisk2DeadRatio = wordReportFacade.findHospCaseRisk2Ratio(paramMap);
				remap.put("hospCaseRisk2DeadRatio", Double.parseDouble(hospCaseRisk2DeadRatio==null?"0":hospCaseRisk2DeadRatio));
		
				// 获取低风险死亡情况科室信息
				List<Object[]> depDeaRisk2List = wordReportFacade.findQualityDepTableByRisk2List(paramMap);
				String depDeaRisk2Most="";
				int depDeaRisk2MostCnt=0;
				String depDeaRisk2Second="";
				int depDeaRisk2SecondCnt=0;
				//int depDeaRisk2Cnt=0;
				List<Map<String, Object>> depDeaRisk2MapList = new ArrayList<Map<String, Object>>();
				if (!depDeaRisk2List.isEmpty()) {
					int index = 0;
					for (Object[] obj : depDeaRisk2List) {
						Map<String, Object> map = new HashMap<String, Object>();
						if (index == 0) {
							depDeaRisk2Most=obj[0] + "";
							depDeaRisk2MostCnt=MonitorResultUtil.objectToDouble(obj[2]==null?"0":obj[2]+"").intValue();
						} else if (index == 1) {
							depDeaRisk2Second=obj[0] + "";
							depDeaRisk2SecondCnt=MonitorResultUtil.objectToDouble(obj[2]==null?"0":obj[2]+"").intValue();
						}
						map.put("order",index+1);
						map.put("dep", obj[0]+"");
						map.put("incnt", obj[1]+"");
						map.put("deadcnt", obj[2]+"");
						map.put("deadRatio",df.format(obj[3])+"");
						depDeaRisk2MapList.add(map);
					//	depDeaRisk2Cnt+=MonitorResultUtil.objectToDouble(obj[2]==null?"0":obj[2]+"").intValue();
						index++;
					}
				} 
				remap.put("depDeaRisk2Most", depDeaRisk2Most);
				remap.put("depDeaRisk2MostCnt","("+ depDeaRisk2MostCnt+"例)");
				remap.put("depDeaRisk2Second", depDeaRisk2Second);
				remap.put("depDeaRisk2SecondCnt","("+ depDeaRisk2SecondCnt+"例)");
				remap.put("depDeaRisk2MapList", depDeaRisk2MapList);
				//remap.put("depDeaRisk2Cnt", depDeaRisk2Cnt);
				//mdc总个数
				int mdcCnt=wordReportFacade.findMdcCnt(paramMap);
				remap.put("mdcCnt", mdcCnt);

				// MDC专业CMI排名表
				List<Object[]> capacityMdcBycmiList = wordReportFacade.findMdcCW(paramMap);
				StringBuffer mdcNameTopByCMI = new StringBuffer();// 技术难度前五名的MDC名称
				List<Map<String, Object>> capacityMdcBycmiMapList = new ArrayList<Map<String, Object>>();
				String mdcNameTopByCMIStr="";
				if (!capacityMdcBycmiList.isEmpty()) {
					int mdcByCMIIndex = 0;
					for (Object[] mdcByCMI : capacityMdcBycmiList) {
						Map<String, Object> map = new HashMap<String, Object>();
						if (mdcByCMIIndex < 5) {
							mdcNameTopByCMI.append(mdcByCMI[0].toString() + "(" + mdcByCMI[1].toString() + ")、");
							map.put("order", mdcByCMIIndex+1);
							map.put("code", mdcByCMI[0]);
							map.put("name", mdcByCMI[1]);
							map.put("cmi", Arith.round(Double.parseDouble(mdcByCMI[2] == null ? "0" : mdcByCMI[2].toString()), 2));
							capacityMdcBycmiMapList.add(map);
						}
						mdcByCMIIndex++;
					}
				}
				if (mdcNameTopByCMI.lastIndexOf("、") > 0) {
					mdcNameTopByCMIStr=mdcNameTopByCMI.substring(0, mdcNameTopByCMI.lastIndexOf("、"))+"";
				}
				remap.put("mdcNameTopByCMIStr", mdcNameTopByCMIStr);
				remap.put("capacityMdcBycmiMapList", capacityMdcBycmiMapList);
				
				
				// MDC专业权重排名表
				List<Object[]> capacityMDCByToalWeightList = wordReportFacade.findCapacityMDCByTotalWeight(paramMap);
				StringBuffer mdcNameTopByweight = new StringBuffer();// 技术难度前五名的MDC名称
				List<Map<String, Object>> capacityMdcByweightMapList = new ArrayList<Map<String, Object>>();
				String mdcNameTopByweightStr="";
				if (!capacityMDCByToalWeightList.isEmpty()) {
					int mdcByweightIndex = 0;
					for (Object[] mdcByweight : capacityMDCByToalWeightList) {
						Map<String, Object> map = new HashMap<String, Object>();
						if (mdcByweightIndex < 5) {
							mdcNameTopByweight.append(mdcByweight[0].toString() + "(" + mdcByweight[1].toString() + ")、");
							map.put("order", mdcByweightIndex+1);
							map.put("code", mdcByweight[0]);
							map.put("name", mdcByweight[1]);
							map.put("weight", Arith.round(Double.parseDouble(mdcByweight[2] == null ? "0" : mdcByweight[2].toString()), 2));
							capacityMdcByweightMapList.add(map);
						}
						mdcByweightIndex++;
					}
				}
				if (mdcNameTopByweight.lastIndexOf("、") > 0) {
					mdcNameTopByweightStr=mdcNameTopByweight.substring(0, mdcNameTopByweight.lastIndexOf("、"))+"";
				}		
				remap.put("mdcavgweight",Arith.div(	MonitorResultUtil.objectToDouble(remap.get("hosptotalweight")==null?"0":remap.get("hosptotalweight")+""),mdcCnt, 2)); 
				remap.put("mdcNameTopByweightStr", mdcNameTopByweightStr);
				remap.put("capacityMdcByweightMapList", capacityMdcByweightMapList);
				
				//mdc cmi和权重
				int mdcCnt1 = 0;
				int mdcCnt2 = 0;
				int mdcCnt3 = 0;
				int mdcCnt4 = 0;
				StringBuffer mdcCW1 = new StringBuffer(); 
				StringBuffer mdcCW2 = new StringBuffer();
				StringBuffer mdcCW3 = new StringBuffer();
				StringBuffer mdcCW4 = new StringBuffer();
				List<Object[]> mdcCWList = wordReportFacade.findMdcCW(paramMap);
				List<Map<String, Object>> mdcnormalCWIMapList = new ArrayList<Map<String, Object>>();
				abnormalMap = new HashMap<String, List<Map<String, Object>>>();
			if (!mdcCWList.isEmpty()) {
					int mwIndex = 0;
					for (Object[] mw : mdcCWList) {
						Map<String, Object> map = new HashMap<String, Object>();
						map.put("order", mwIndex+1);
						map.put("mdc", mw[0]);
						map.put("mdcdesc", mw[1]);
						map.put("cmi", Arith.round(Double.parseDouble(mw[2] == null ? "0" : mw[2].toString()), 2));
						map.put("weight", Arith.round(Double.parseDouble(mw[3] == null ? "0" : mw[3].toString()), 2));
						mdcnormalCWIMapList.add(map);
						mwIndex++;
					}
				}
				
				//压入不正常的数据
				String mdcCWAbnormal="";
				if(isAbno==1){
					abnormalMap = abnorm.getAbnormalDataMap(mdcnormalCWIMapList, "weight", "cmi");//计算是否有异常数据
					List<Map<String, Object>> mdcAbnormalWeightAndCMIList = abnormalMap.get("abnorMapList");// 异常数据
					mdcnormalCWIMapList = abnormalMap.get("norMapList");// 参与计算数据
					StringBuffer mdcCmiWeightAbnormal = new StringBuffer();				
					for (Map<String, Object> map : mdcAbnormalWeightAndCMIList) {
						Double weight = MonitorResultUtil.objectToDouble(String.valueOf(map.get("weight") == null ? 0 : map.get("weight")));
						Double cmi = MonitorResultUtil.objectToDouble(String.valueOf(map.get("cmi") == null ? 0 : map.get("cmi")));
						mdcCmiWeightAbnormal.append(map.get("mdc") + "(" + cmi + "," + weight + ")、");
					}
					if (mdcCmiWeightAbnormal.lastIndexOf("、") > 0) {
						mdcCWAbnormal= mdcCmiWeightAbnormal.substring(0, mdcCmiWeightAbnormal.lastIndexOf("、"))+"";
						remap.put("mdcCWAbnormal",mdcCWAbnormal+"作为特异数据未显示在下图中。");
					}else{
						remap.put("mdcCWAbnormal"," ");
					}
					
				}else{
					mdcnormalCWIMapList=mdcnormalCWIMapList;
					remap.put("mdcCWAbnormal",mdcCWAbnormal);
				}	
				Double mdcmiddleWeight=imputedMiddleWeight(mdcnormalCWIMapList);
				Double mdcmiddleCmi=imputedMiddleCmi(mdcnormalCWIMapList);
				for (Map<String, Object> map : mdcnormalCWIMapList) {
					Double weight = MonitorResultUtil.objectToDouble(String.valueOf(map.get("weight") == null ? 0 : map.get("weight")));
					Double cmi = MonitorResultUtil.objectToDouble(String.valueOf(map.get("cmi") == null ? 0 : map.get("cmi")));
					if (weight > mdcmiddleWeight && cmi > mdcmiddleCmi) {
						mdcCnt1++;
						mdcCW1.append(map.get("mdcdesc") + "(" + cmi + "," + weight + ")、");
					} else if (weight > mdcmiddleWeight && cmi <= mdcmiddleCmi) {
						mdcCnt2++;
						mdcCW2.append(map.get("mdcdesc") + "(" + cmi + "," + weight + ")、");
					} else if (weight <= mdcmiddleWeight && cmi <= mdcmiddleCmi) {
						mdcCnt3++;
						mdcCW3.append(map.get("mdcdesc") + "(" + cmi + "," + weight + ")、");
					} else if (weight <= mdcmiddleWeight && cmi > mdcmiddleCmi) {
						mdcCnt4++;
						mdcCW4.append(map.get("mdcdesc") + "(" + cmi + "," + weight + ")、");
					}
				}
			
				String	mdcCW1Str="--";
				String	mdcCW2Str="--";
				String	mdcCW3Str="--";
				String	mdcCW4Str="--";
				if (mdcCW1.lastIndexOf("、") > 0) {
					mdcCW1Str=mdcCW1.substring(0, mdcCW1.lastIndexOf("、"))+"";
				}
				if (mdcCW2.lastIndexOf("、") > 0) {
					mdcCW2Str=mdcCW2.substring(0, mdcCW2.lastIndexOf("、"))+"";
				}
				if (mdcCW3.lastIndexOf("、") > 0) {
					mdcCW3Str=mdcCW3.substring(0, mdcCW3.lastIndexOf("、"))+"";
				}
				if (mdcCW4.lastIndexOf("、") > 0) {
					mdcCW4Str=mdcCW4.substring(0, mdcCW4.lastIndexOf("、"))+"";
				}
				remap.put("mdcmiddleWeight", mdcmiddleWeight);	 //中位数
				remap.put("mdcmiddleCmi", mdcmiddleCmi);	//中位数
				remap.put("mdcCnt1", mdcCnt1);	//个数
				remap.put("mdcCnt2", mdcCnt2);	
				remap.put("mdcCnt3", mdcCnt3);	
				remap.put("mdcCnt4", mdcCnt4);
				
				remap.put("mdcCW1Str", mdcCW1Str);//具体
				remap.put("mdcCW2Str", mdcCW2Str);
				remap.put("mdcCW3Str", mdcCW3Str);
				remap.put("mdcCW4Str", mdcCW4Str);
				remap.put("mdcnormalCWIMapList", mdcnormalCWIMapList);
				
				//mdc的时间费用消耗指数
				List<Object[]> mdcFTList = wordReportFacade.findImage3FeeAndTimeEff(paramMap);
			
				//时间消耗
				List<Map<String, Object>> mdcTimeMapList = new ArrayList<Map<String, Object>>();
				StringBuffer mdcfeetop5= new StringBuffer();
				String mdcfeetop5str="";
				int mdcfeeover1=0;
				int mdcfeecaseover1=0;
					//获取费用消耗指数
					List<Object[]> mdcFeeList = wordReportFacade.findImage3Fee(paramMap);
					List<Map<String, Object>> mdcFeeMapList = new ArrayList<Map<String, Object>>();
						if(!mdcFTList.isEmpty()){
							for(int i=0;i<mdcFeeList.size();i++){
								Object[] obj=mdcFeeList.get(i);
								Map<String, Object> map = new HashMap<String, Object>();
								if(i<5){
									mdcfeetop5.append(""+obj[0]+"("+obj[1]+")、");
									map.put("order", i+1);
									map.put("mdc", obj[0] + "");
									map.put("mdcdesc",obj[1] + "");
									map.put("fee", Arith.round(Double.parseDouble((obj[2] == null ? 0 : obj[2]) + ""), 2));
									map.put("time", Arith.round(Double.parseDouble((obj[3] == null ? 0 : obj[3]) + ""), 2));
									mdcFeeMapList.add(map);
								}
								if(MonitorResultUtil.objectToDouble(obj[2]==null?"0":obj[2]+"")>1){
									mdcfeeover1++;
									mdcfeecaseover1+=MonitorResultUtil.objectToDouble(obj[4]==null?"0":obj[4]+"").intValue();
								}
								
								
							}
						}
						if(mdcfeetop5.lastIndexOf("、")>0){
							mdcfeetop5str=mdcfeetop5.substring(0,mdcfeetop5.lastIndexOf("、"));
						}
						remap.put("mdcfeeover1", mdcfeeover1);
						remap.put("mdcfeecaseover1", mdcfeecaseover1);
						remap.put("mdcfeeover1caseratio", imputedRatio(MonitorResultUtil.objectToDouble(mdcfeecaseover1),MonitorResultUtil.objectToDouble(remap.get("ingroupcasecnt")+"")));
						remap.put("mdcfeetop5str", mdcfeetop5str);//
						remap.put("mdcFeeMapList", mdcFeeMapList);//费用消耗
						
					//mdc时间消耗指数
					StringBuffer mdctimetop5= new StringBuffer();
					String mdctimetop5str="";
					int mdctimeover1=0;
					int mdctimecaseover1=0;
						if(!mdcFTList.isEmpty()){
							for(int i=0;i<mdcFTList.size();i++){
								Object[] obj=mdcFTList.get(i);
								Map<String, Object> map = new HashMap<String, Object>();
								if(i<5){
									mdctimetop5.append(""+obj[0]+"("+obj[1]+")、");
									map.put("order", i+1);
									map.put("mdc", obj[0] + "");
									map.put("mdcdesc",obj[1] + "");
									map.put("fee", Arith.round(Double.parseDouble((obj[2] == null ? 0 : obj[2]) + ""), 2));
									map.put("time", Arith.round(Double.parseDouble((obj[3] == null ? 0 : obj[3]) + ""), 2));
									mdcTimeMapList.add(map);
								}
								if(MonitorResultUtil.objectToDouble(obj[3]==null?"0":obj[3]+"")>1){
									mdctimeover1++;
									mdctimecaseover1+=MonitorResultUtil.objectToDouble(obj[4]==null?"0":obj[4]+"").intValue();
								}
							}
						}	
						if(mdctimetop5.lastIndexOf("、")>0){
							mdctimetop5str=mdctimetop5.substring(0,mdctimetop5.lastIndexOf("、"));
						}
						
						remap.put("mdctimeover1", mdctimeover1);
						remap.put("mdctimecaseover1", mdctimecaseover1);
						remap.put("mdctimeover1caseratio", imputedRatio(MonitorResultUtil.objectToDouble(mdctimecaseover1),MonitorResultUtil.objectToDouble(remap.get("ingroupcasecnt")+"")));
						remap.put("mdctimetop5str", mdctimetop5str);
						remap.put("mdctimeMapList", mdcTimeMapList);
						
						
						
					
						// MDC--费用消耗指数--时间消耗指数
						StringBuffer mdcFeeET1 = new StringBuffer();
						StringBuffer mdcFeeET2 = new StringBuffer();
						StringBuffer mdcFeeET3 = new StringBuffer();
						StringBuffer mdcFeeET4 = new StringBuffer();
						String mdcFeeET1Str="--";
						String mdcFeeET2Str="--";
						String mdcFeeET3Str="--";
						String mdcFeeET4Str="--";
						int mdcFT1=0;int mdcFT2=0;int mdcFT3=0;int mdcFT4=0;
						List<Map<String, Object>> mdcFTMapList = new ArrayList<Map<String, Object>>();
						StringBuffer mdcFTAbnormal = new StringBuffer();
						String mdcFTAbnormalStr = "--";
						//mdcFTMapList=mdcFeeMapList;
						
						if(!mdcFTList.isEmpty()){
							for(int i=0;i<mdcFTList.size();i++){
								Object[] obj=mdcFTList.get(i);
								Map<String, Object> map1 = new HashMap<String, Object>();
									map1.put("order", i+1);
									map1.put("mdc", obj[0] + "");
									map1.put("mdcdesc",obj[1] + "");
									map1.put("fee", Arith.round(Double.parseDouble((obj[2] == null ? 0 : obj[2]) + ""), 2));
									map1.put("time", Arith.round(Double.parseDouble((obj[3] == null ? 0 : obj[3]) + ""), 2));
									mdcFTMapList.add(map1);
							}
						}	
						
						
						
						
						if(isAbno==1){
							// 检测时间费用消耗指数异常数据
							abnormalMap = new HashMap<String, List<Map<String, Object>>>();
							abnormalMap = abnorm.getAbnormalDataMap(mdcFTMapList, "fee", "time");
							List<Map<String, Object>> mdcFTAbnormalList = abnormalMap.get("abnorMapList");// 异常数据
							List<Map<String, Object>> mdcFTnormalList = abnormalMap.get("norMapList");// 参与计算数据
							mdcFTMapList=mdcFTnormalList;
							for (Map<String, Object> map : mdcFTAbnormalList) {
								Double fee = MonitorResultUtil.objectToDouble(String.valueOf(map.get("fee") == null ? 0 : map.get("fee")));
								Double time = MonitorResultUtil.objectToDouble(String.valueOf(map.get("time") == null ? 0 : map.get("time")));
								mdcFTAbnormal.append(map.get("mdc") + "(" + time + "," + fee + ")、");
							}
							if (mdcFTAbnormal.lastIndexOf("、") > 0) {
								mdcFTAbnormalStr= mdcFTAbnormal.substring(0, mdcFTAbnormal.lastIndexOf("、"))+"";
								remap.put("mdcFTAbnormalStr",mdcFTAbnormalStr+"作为特异数据未显示在下图中。");
							}else{
								remap.put("mdcFTAbnormalStr",mdcFTAbnormalStr);
							}
						}else{
							remap.put("mdcFTAbnormalStr",mdcFTAbnormalStr);
						}
						for (Map<String, Object> map : mdcFTMapList) {
							Double fee = MonitorResultUtil.objectToDouble(String.valueOf(map.get("fee") == null ? 0 : map.get("fee")));
							Double time = MonitorResultUtil.objectToDouble(String.valueOf(map.get("time") == null ? 0 : map.get("time")));
							if (fee >1 && time > 1) {
								mdcFT1++;
								mdcFeeET1.append(map.get("mdcdesc") + "(" + time + "," + fee + ")、");
							} else if (fee > 1 && time <= 1) {
								mdcFT2++;
								mdcFeeET2.append(map.get("mdcdesc") + "(" + time + "," + fee + ")、");
							} else if (fee <= 1 && time <= 1) {
								mdcFT3++;
								mdcFeeET3.append(map.get("mdcdesc") + "(" + time + "," + fee + ")、");
							} else if (fee <=1 && time > 1) {
								mdcFT4++;
								mdcFeeET4.append(map.get("mdcdesc") + "(" + time + "," + fee + ")、");
							}

						}
				
						if (mdcFeeET1.lastIndexOf("、") > 0) {
							mdcFeeET1Str=mdcFeeET1.substring(0, mdcFeeET1.lastIndexOf("、"));
						}
						if (mdcFeeET2.lastIndexOf("、") > 0) {
							mdcFeeET2Str=mdcFeeET2.substring(0, mdcFeeET2.lastIndexOf("、"));
						}
						if (mdcFeeET4.lastIndexOf("、") > 0) {
							mdcFeeET4Str=mdcFeeET4.substring(0, mdcFeeET4.lastIndexOf("、"));
						}
						if (mdcFeeET3.lastIndexOf("、") > 0) {
							mdcFeeET3Str=mdcFeeET3.substring(0, mdcFeeET3.lastIndexOf("、"));
						}
						remap.put("mdcFT1", mdcFT1);
						remap.put("mdcFT2", mdcFT2);
						remap.put("mdcFT3", mdcFT3);
						remap.put("mdcFT4", mdcFT4);
						
						remap.put("mdcFeeET1Str", mdcFeeET1Str);
						remap.put("mdcFeeET2Str", mdcFeeET2Str);
						remap.put("mdcFeeET3Str", mdcFeeET3Str);
						remap.put("mdcFeeET4Str", mdcFeeET4Str);
						remap.put("mdcFTMapList", mdcFTMapList);
					//mdc低风险
					List<Object[]> mdcFTRisk1List = wordReportFacade.mdcFTRisk1List(paramMap);
					List<Map<String, Object>> mdcFTRisk1MapList = new ArrayList<Map<String, Object>>();
					String mdcrisk1most="--";
					int mdcrisk1mostcnt=0;
					String mdcrisk1second="--";
					int mdcrisk1secondcnt=0;
					int mdcrisk1deadcnt=0;
					if(!mdcFTRisk1List.isEmpty()){
						int i=1;
						for(Object[] obj:mdcFTRisk1List){
							Map<String, Object> map = new HashMap<String, Object>();
							mdcrisk1deadcnt+=Integer.parseInt(obj[3]==null?"0":obj[3]+"");
							if(i==1){
								mdcrisk1most=obj[0]+"("+obj[1]+")";
								mdcrisk1mostcnt=Integer.parseInt(obj[3]==null?"0":obj[3]+"");
							}
							if(i==2){
								mdcrisk1second=obj[0]+"("+obj[1]+")";
								mdcrisk1secondcnt=Integer.parseInt(obj[3]==null?"0":obj[3]+"");
							}
							map.put("order",i);
							map.put("mdcCode", obj[0]+"");
							map.put("mdcDesc", obj[1]+"");
							map.put("inCnt", obj[2]+"");
							map.put("deadCnt", obj[3]+"");
							map.put("deadRatio", df.format(obj[4]==null?0:obj[4]));
							mdcFTRisk1MapList.add(map);
							i++;
						}
						
					}
					
					remap.put("mdcrisk1deadcnt", mdcrisk1deadcnt);
					remap.put("mdcrisk1most", mdcrisk1most);
					remap.put("mdcrisk1mostcnt", mdcrisk1mostcnt);
					remap.put("mdcrisk1second", mdcrisk1second);
					remap.put("mdcrisk1secondcnt", mdcrisk1secondcnt);
					remap.put("mdcFTRisk1MapList", mdcFTRisk1MapList);
					//mdc中低风险
					List<Object[]> mdcFTRisk2List = wordReportFacade.mdcFTRisk2List(paramMap);
					List<Map<String, Object>> mdcFTRisk2MapList = new ArrayList<Map<String, Object>>();
					String mdcRisk2most="--";
					int mdcRisk2mostcnt=0;
					String mdcRisk2second="--";
					int mdcRisk2secondcnt=0;
					int mdcRisk2deadcnt=0;
					if(!mdcFTRisk2List.isEmpty()){
						int i=1;
						for(Object[] obj:mdcFTRisk2List){
							Map<String, Object> map = new HashMap<String, Object>();
							mdcRisk2deadcnt+=Integer.parseInt(obj[3]==null?"0":obj[3]+"");
							if(i==1){
								mdcRisk2most=obj[0]+"("+obj[1]+")";
								mdcRisk2mostcnt=Integer.parseInt(obj[3]==null?"0":obj[3]+"");
							}
							if(i==2){
								mdcRisk2second=obj[0]+"("+obj[1]+")";
								mdcRisk2secondcnt=Integer.parseInt(obj[3]==null?"0":obj[3]+"");
							}
							map.put("order",i);
							map.put("mdcCode", obj[0]+"");
							map.put("mdcDesc", obj[1]+"");
							map.put("inCnt", obj[2]+"");
							map.put("deadCnt", obj[3]+"");
							map.put("deadRatio",obj[4]+"");
							mdcFTRisk2MapList.add(map);
							i++;
						}
					}
					remap.put("mdcrisk2deadcnt",mdcRisk2deadcnt);
					remap.put("mdcrisk2most", mdcRisk2most);
					remap.put("mdcrisk2mostcnt", mdcRisk2mostcnt);
					remap.put("mdcrisk2second", mdcRisk2second);
					remap.put("mdcrisk2secondcnt", mdcRisk2secondcnt);
					remap.put("mdcFTRisk2MapList", mdcFTRisk2MapList);
					//////////////////////////////////////
					//**********************第六章开始*****************************
					List<Object[]> hospdep1 = wordReportFacade.findHospdep1(paramMap);
					List<Object[]> hospdep2 = wordReportFacade.findHospdep2(paramMap);
					
					if(!hospdep1.isEmpty()){
						for(Object[] obj:hospdep1){
						remap.put("hospdep1_1", obj[0]==null?0:obj[0]);//累计出院病历
						remap.put("hospdep1_2", obj[1]==null?0:obj[1]);//占比（%）
						}
					}else{
						remap.put("hospdep1_1", "--");
						remap.put("hospdep1_2", "--");
					}
					
					if(!hospdep2.isEmpty()){
						for(Object[] obj:hospdep2){
						remap.put("hospdep2_1", obj[0]==null?0:obj[0]);//入组病历
						remap.put("hospdep2_2", obj[1]==null?0:obj[1]);//覆盖病组
						remap.put("hospdep2_3", obj[2]==null?0:obj[2]);//mdc专业
						}
						
					}else{
						remap.put("hospdep2_1", "--");
						remap.put("hospdep2_2", "--");
						remap.put("hospdep2_3", "--");
					}
					List<Object[]> hospdep3 = wordReportFacade.findHospdep3(paramMap);
					if(!hospdep3.isEmpty()){
						for(Object[] obj:hospdep3){
						remap.put("hospdep3_1", obj[0]==null?0:obj[0]);//mdc专业
						remap.put("hospdep3_2", obj[1]==null?0:obj[1]);//mdc名称
						remap.put("hospdep3_3", obj[2]==null?0:obj[2]);//病例数占比
						}
						
					}else{
						remap.put("hospdep3_1", "--");
						remap.put("hospdep3_2", "--");
						remap.put("hospdep3_3", "--");
					}
					String fristhospdepmdc=remap.get("hospdep3_1").toString();
					paramMap.put("fristhospdepmdc", fristhospdepmdc);
					List<Object[]> hospdep4 = wordReportFacade.findHospdep4(paramMap);
					if(!hospdep4.isEmpty()){
						for(Object[] obj:hospdep4){
						remap.put("hospdep4_1", obj[0]==null?0:obj[0]);//quan院MDCI专业收治病例
						remap.put("hospdep4_2", obj[1]==null?0:obj[1]);//骨科收治全院MDCI专业
						}
						
					}else{
						remap.put("hospdep4_1", "--");
						remap.put("hospdep4_2", "--");
					
					}
					List<Object[]> findtable61 = wordReportFacade.findtable61(paramMap);
					List<Map<String, Object>> findtable61mapList = new ArrayList<Map<String, Object>>();
					double table61top5ratio=0;
					if(!findtable61.isEmpty()){
						int i=1;
						
						for(Object[] obj:findtable61){
							Map<String, Object> map = new HashMap<String, Object>();
							if(i<=5)
							{
							map.put("order",i);
							map.put("table61_1", obj[0]+"");
							map.put("table61_2", obj[1]+"");
							map.put("table61_3", obj[2]+"");
							map.put("table61_4", obj[3]+"");
							map.put("table61_5", obj[4]+"");
							findtable61mapList.add(map);
							table61top5ratio+=MonitorResultUtil.objectToDouble(obj[3]==null?"0":obj[3]+"");
							}
							i++;
						}
						
					}
					remap.put("table61top5ratio", table61top5ratio);
					remap.put("findtable61mapList", findtable61mapList);
					
					List<Object[]> hospdep5 = wordReportFacade.findHospdep5(paramMap);
					if(!hospdep5.isEmpty()){
						
						for(Object[] obj:hospdep5){
						remap.put("hospdep5_1", obj[0]==null?0:obj[0]);//mdc专业
						remap.put("hospdep5_2", obj[1]==null?0:obj[1]);//mdc名称
						remap.put("hospdep5_3", obj[2]==null?0:obj[2]);//病例数占比
						}
					}else{
						remap.put("hospdep5_1", "--");
						remap.put("hospdep5_2", "--");
						remap.put("hospdep5_3", "--");
					}
					List<Object[]> findtable62 = wordReportFacade.findtable62(paramMap);
					List<Map<String, Object>> findtable62mapList = new ArrayList<Map<String, Object>>();
					double table62top5ratio=0;
					if(!findtable62.isEmpty()){
						int i=1;
						
						for(Object[] obj:findtable62){
							Map<String, Object> map = new HashMap<String, Object>();
							if(i<=5)
							{
							map.put("order",i);
							map.put("table62_1", obj[0]+"");
							map.put("table62_2", obj[1]+"");
							map.put("table62_3", obj[2]+"");
							map.put("table62_4", obj[3]+"");
							map.put("table62_5", obj[4]+"");
							findtable62mapList.add(map);
							table62top5ratio+=MonitorResultUtil.objectToDouble(obj[4]==null?"0":obj[4]+"");
							}
							i++;
						}
						
					}
					remap.put("table62top5ratio",table62top5ratio);
					remap.put("findtable62mapList", findtable62mapList);
					//6.1.3  效率分析*************************************************
					List<Object[]> findtable63 = wordReportFacade.findtable63(paramMap);
				    List<Map<String, Object>> findtable63mapList = new ArrayList<Map<String, Object>>();
					//重点科室mdc时间费率
					
					StringBuffer depmdcFeeET1 = new StringBuffer();
					StringBuffer depmdcFeeET2 = new StringBuffer();
					StringBuffer depmdcFeeET3 = new StringBuffer();
					StringBuffer depmdcFeeET4 = new StringBuffer();
					String depmdcFeeET1Str="--";
					String depmdcFeeET2Str="--";
					String depmdcFeeET3Str="--";
					String depmdcFeeET4Str="--";
					int depmdcFT1=0;int depmdcFT2=0;int depmdcFT3=0;int depmdcFT4=0;
					
					StringBuffer depmdcFTAbnormal = new StringBuffer();
					String depmdcFTAbnormalStr = "--";
					//mdcFTMapList=mdcFeeMapList;
					
					if(!findtable63.isEmpty()){
						for(int i=0;i<findtable63.size();i++){
							Object[] obj=findtable63.get(i);
							Map<String, Object> map1 = new HashMap<String, Object>();
								map1.put("order", i+1);
								map1.put("table63_mdc", obj[0] + "");
								map1.put("table63_mdcdesc",obj[1] + "");
								map1.put("table63_fee", obj[2] + "");
								map1.put("table63_time", obj[3] + "");
								findtable63mapList.add(map1);
						}
					}	
					
					
					
					
					if(isAbno==1){
						// 检测时间费用消耗指数异常数据
						abnormalMap = new HashMap<String, List<Map<String, Object>>>();
						abnormalMap = abnorm.getAbnormalDataMap(findtable63mapList, "table63_fee", "table63_time");
						List<Map<String, Object>> depmdcFTAbnormalList = abnormalMap.get("abnorMapList");// 异常数据
						List<Map<String, Object>> depmdcFTnormalList = abnormalMap.get("norMapList");// 参与计算数据
						findtable63mapList=depmdcFTnormalList;
						for (Map<String, Object> map : depmdcFTAbnormalList) {
							Double table63_fee = MonitorResultUtil.objectToDouble(String.valueOf(map.get("table63_fee") == null ? 0 : map.get("table63_fee")));
							Double table63_time = MonitorResultUtil.objectToDouble(String.valueOf(map.get("table63_time") == null ? 0 : map.get("table63_time")));
							depmdcFTAbnormal.append(map.get("table63_mdc") + "(" + table63_time + "," + table63_fee + ")、");
						}
						if (depmdcFTAbnormal.lastIndexOf("、") > 0) {
							depmdcFTAbnormalStr= depmdcFTAbnormal.substring(0, depmdcFTAbnormal.lastIndexOf("、"))+"";
							remap.put("mdcFTAbnormalStr",depmdcFTAbnormalStr+"作为特异数据未显示在下图中。");
						}else{
							remap.put("mdcFTAbnormalStr",depmdcFTAbnormalStr);
						}
					}else{
						remap.put("mdcFTAbnormalStr",depmdcFTAbnormalStr);
					}
					for (Map<String, Object> map : findtable63mapList) {
						Double table63_fee = MonitorResultUtil.objectToDouble(String.valueOf(map.get("table63_fee") == null ? 0 : map.get("table63_fee")));
						Double table63_time = MonitorResultUtil.objectToDouble(String.valueOf(map.get("table63_time") == null ? 0 : map.get("table63_time")));
						if (table63_fee >1 && table63_time > 1) {
							depmdcFT1++;
							depmdcFeeET1.append(map.get("table63_mdcdesc") + "(" + table63_time + "," + table63_fee + ")、");
						} else if (table63_fee > 1 && table63_time <= 1) {
							depmdcFT2++;
							depmdcFeeET2.append(map.get("table63_mdcdesc") + "(" + table63_time + "," + table63_fee + ")、");
						} else if (table63_fee <= 1 && table63_time <= 1) {
							depmdcFT3++;
							depmdcFeeET3.append(map.get("table63_mdcdesc") + "(" + table63_time + "," + table63_fee + ")、");
						} else if (table63_fee <=1 && table63_time > 1) {
							depmdcFT4++;
							depmdcFeeET4.append(map.get("table63_mdcdesc") + "(" + table63_time + "," + table63_fee + ")、");
						}

					}
			
					if (depmdcFeeET1.lastIndexOf("、") > 0) {
						depmdcFeeET1Str=depmdcFeeET1.substring(0, depmdcFeeET1.lastIndexOf("、"));
					}
					if (depmdcFeeET2.lastIndexOf("、") > 0) {
						depmdcFeeET2Str=depmdcFeeET2.substring(0, depmdcFeeET2.lastIndexOf("、"));
					}
					if (depmdcFeeET4.lastIndexOf("、") > 0) {
						depmdcFeeET4Str=depmdcFeeET4.substring(0, depmdcFeeET4.lastIndexOf("、"));
					}
					if (depmdcFeeET3.lastIndexOf("、") > 0) {
						depmdcFeeET3Str=depmdcFeeET3.substring(0, depmdcFeeET3.lastIndexOf("、"));
					}
					int gt1deptime = depmdcFT1+depmdcFT4;//时间大于1的个数
					int gt1depfee  = depmdcFT2+depmdcFT1;//费率大于1的个数
					remap.put("gt1deptime", gt1deptime);
					remap.put("gt1depfee", gt1depfee);
					
					remap.put("depmdcFT1", depmdcFT1);
					remap.put("depmdcFT2", depmdcFT2);
					remap.put("depmdcFT3", depmdcFT3);
					remap.put("depmdcFT4", depmdcFT4);
					
					remap.put("depmdcFeeET1Str", depmdcFeeET1Str);
					remap.put("depmdcFeeET2Str", depmdcFeeET2Str);
					remap.put("depmdcFeeET3Str", depmdcFeeET3Str);
					remap.put("depmdcFeeET4Str", depmdcFeeET4Str);
					remap.put("findtable63mapList", findtable63mapList);
					
					List<Object[]> findtable63timetop5 = wordReportFacade.findtable63timetop5(paramMap);
					List<Map<String, Object>> findtable63timetop5mapList = new ArrayList<Map<String, Object>>();
					if(!findtable63timetop5.isEmpty()){
						int i=1;
						for(Object[] obj:findtable63timetop5){
							Map<String, Object> map = new HashMap<String, Object>();
							StringBuffer table63timetop5= new StringBuffer() ;
							if(i<=5)
							{
								if(i<=4){
							     table63timetop5.append(obj[0]+"-"+obj[1]+"("+obj[2]+")"+"、");
							     map.put("table63timetop5", table63timetop5);
							     findtable63timetop5mapList.add(map);}
								else{
									table63timetop5.append(obj[0]+"-"+obj[1]+"("+obj[2]+")"+"。");
								     map.put("table63timetop5", table63timetop5);
								     findtable63timetop5mapList.add(map);
								}
							}
							i++;
						}
					}
					remap.put("findtable63timetop5mapList", findtable63timetop5mapList);
					
					List<Object[]> findtable63feetop5 = wordReportFacade.findtable63feetop5(paramMap);
					List<Map<String, Object>> findtable63feetop5mapList = new ArrayList<Map<String, Object>>();
					if(!findtable63feetop5.isEmpty()){
						int i=1;
						for(Object[] obj:findtable63feetop5){
							Map<String, Object> map = new HashMap<String, Object>();
							StringBuffer table63feetop5=new StringBuffer();
							if(i<=5)
							{
								if(i<=4){
								table63feetop5.append(obj[0]+"-"+obj[1]+"("+obj[2]+")"+"、");
								map.put("table63feetop5", table63feetop5);
								findtable63feetop5mapList.add(map);}
								else{
									table63feetop5.append(obj[0]+"-"+obj[1]+"("+obj[2]+")"+"。");
									map.put("table63feetop5", table63feetop5);
									findtable63feetop5mapList.add(map);
								}
							}
							i++;
						}
					}
					remap.put("findtable63feetop5mapList", findtable63feetop5mapList);
					
					List<Object[]> hospdep64 = wordReportFacade.findhospdep64(paramMap);//死亡病例分布
					if(!hospdep64.isEmpty()){
						for(Object[] obj:hospdep64){
						remap.put("hospdep64_1", obj[0]==null?0:obj[0]);//骨科累计出院病历
						remap.put("hospdep64_2", obj[1]==null?0:obj[1]);//死亡病例
						remap.put("hospdep64_3", obj[2]==null?0:obj[2]);//死亡率
						}
					}else{
						remap.put("hospdep64_1", "--");
						remap.put("hospdep64_2", "--");
						remap.put("hospdep64_3", "--");
					}
					//骨科死亡人数MDC专业分布表
					List<Object[]> findtable64 = wordReportFacade.findtable64(paramMap);
					List<Map<String, Object>> findtable64List = new ArrayList<Map<String, Object>>();
					StringBuffer fristmdc=new StringBuffer();
					double fristmdccnt=0;
					double zongmdccnt=0;//入组后的死亡病例
					if(!findtable64.isEmpty()){
						int i=1;
						for(Object[] obj:findtable64){
							Map<String, Object> map = new HashMap<String, Object>();
							if(i<=5)
							{
								if(i==1){
									fristmdc.append(obj[0]+"");
									fristmdccnt=MonitorResultUtil.objectToDouble(obj[3]+"");
								}
								map.put("order", i);
								map.put("table64_1", obj[0]+"");
								map.put("table64_2", obj[1]+"");
								map.put("table64_3", obj[2]+"");
								map.put("table64_4", obj[3]+"");
								map.put("table64_5", obj[4]+"");
								findtable64List.add(map);
								zongmdccnt+=Integer.valueOf(obj[3]+"");
							}
							i++;
						}
					}
					remap.put("fristmdc", fristmdc);//骨科最高死亡mdc
					remap.put("fristmdccnt", fristmdccnt);//死亡病例
					remap.put("submdccnt",Arith.sub(zongmdccnt, MonitorResultUtil.objectToDouble(remap.get("hospdep64_2")+"")));
					remap.put("findtable64List", findtable64List);
					
					//DRGs病组分布
					List<Object[]> findtable65 = wordReportFacade.findtable65(paramMap);
					List<Map<String, Object>> findtable65List = new ArrayList<Map<String, Object>>();
					int table65_binglicnt=0;
					double table65_bingliratio=0;
					if(!findtable65.isEmpty()){
						int i=1;
						for(Object[] obj:findtable65){
							Map<String, Object> map = new HashMap<String, Object>();
							if(i<=10)
							{
								map.put("order", i);
								map.put("table65_1", obj[0]+"");
								map.put("table65_2", obj[1]+"");
								map.put("table65_3", obj[2]+"");
								map.put("table65_4", obj[3]+"");
								map.put("table65_5", obj[4]+"");
								findtable65List.add(map);
								table65_binglicnt+=Integer.valueOf(obj[2]+"");
								table65_bingliratio+=MonitorResultUtil.objectToDouble(obj[3]+"");
							}
							i++;
						}
					}
					remap.put("table65_binglicnt", table65_binglicnt);//出院病例数最多的前十个DRGs病组累计病例
					remap.put("table65_bingliratio", table65_bingliratio);//总占比
					remap.put("findtable65List", findtable65List);
					
					//骨科科室下总权重排名前十名的病组情况
					List<Object[]> findtable66 = wordReportFacade.findtable66(paramMap);
					List<Map<String, Object>> findtable66List = new ArrayList<Map<String, Object>>();
					double table66_binglicnt=0;
					if(!findtable66.isEmpty()){
						int i=1;
						for(Object[] obj:findtable66){
							Map<String, Object> map = new HashMap<String, Object>();
							if(i<=10)
							{
								map.put("order", i);
								map.put("table66_1", obj[0]+"");
								map.put("table66_2", obj[1]+"");
								map.put("table66_3", obj[2]+"");
								map.put("table66_4", obj[3]+"");
								map.put("table66_5", obj[4]+"");
								map.put("table66_6", obj[5]+"");
								findtable66List.add(map);
								table66_binglicnt+=MonitorResultUtil.objectToDouble(obj[3]+"");
							}
							i++;
						}
					}
					remap.put("table66_binglicnt", table66_binglicnt);//总权重最多的前十个DRGs病组累计病例
					remap.put("table66_bingliratio", Arith.div(MonitorResultUtil.objectToDouble(remap.get("hospdep64_1")+""), table66_binglicnt));//总占比
					remap.put("findtable66List", findtable66List);
					
					//骨科DRGs病组象限分布图
					List<Object[]> findchart15 = wordReportFacade.findchart15(paramMap);
					List<Map<String, Object>> findchart15mapList = new ArrayList<Map<String, Object>>();
					
					StringBuffer depdrgsFeeET1 = new StringBuffer();
					StringBuffer depdrgsFeeET2 = new StringBuffer();
					StringBuffer depdrgsFeeET3 = new StringBuffer();
					StringBuffer depdrgsFeeET4 = new StringBuffer();
					String depdrgsFeeET1Str="--";
					String depdrgsFeeET2Str="--";
					String depdrgsFeeET3Str="--";
					String depdrgsFeeET4Str="--";
					int depdrgsFT1=0;int depdrgsFT2=0;int depdrgsFT3=0;int depdrgsFT4=0;
					
					StringBuffer depdrgsFTAbnormal = new StringBuffer();
					String depdrgsFTAbnormalStr = "--";
					
					
					if(!findchart15.isEmpty()){
						for(int i=0;i<findchart15.size();i++){
							Object[] obj=findchart15.get(i);
							Map<String, Object> map1 = new HashMap<String, Object>();
								map1.put("order", i+1);
								map1.put("chart15_drgs", obj[0] + "");
								map1.put("chart15_drgsdesc",obj[1] + "");
								map1.put("chart15_fee", obj[2]+ "");
								map1.put("chart15_time",  obj[3]+ "");
								findchart15mapList.add(map1);
						}
					}	
					
					
					
					StringBuffer Abnormal = new StringBuffer();
					String AbnormalStr="";
					if(isAbno==1){
						// 检测时间费用消耗指数异常数据
						abnormalMap = new HashMap<String, List<Map<String, Object>>>();
						abnormalMap = abnorm.getAbnormalDataMap(findchart15mapList, "chart15_fee", "chart15_time");
						List<Map<String, Object>> depdrgsFTAbnormalList = abnormalMap.get("abnorMapList");// 异常数据
						List<Map<String, Object>> depdrgsFTnormalList = abnormalMap.get("norMapList");// 参与计算数据
						findchart15mapList=depdrgsFTnormalList;
						int i=0;
						for (Map<String, Object> map : depdrgsFTAbnormalList) {
							Double chart15_fee = MonitorResultUtil.objectToDouble(String.valueOf(map.get("chart15_fee") == null ? 0 : map.get("chart15_fee")));
							Double chart15_time = MonitorResultUtil.objectToDouble(String.valueOf(map.get("chart15_time") == null ? 0 : map.get("chart15_time")));
							depdrgsFTAbnormal.append(map.get("chart15_drgs") +"-"+map.get("chart15_drgsdesc") +  "(" + chart15_time + "," + chart15_fee + ")、");
							Abnormal.append("'" + map.get("chart15_drgs") + "',");
						}
						if (depdrgsFTAbnormal.lastIndexOf("、") > 0) {
							depdrgsFTAbnormalStr= depdrgsFTAbnormal.substring(0, depdrgsFTAbnormal.lastIndexOf("、"))+"";
							remap.put("drgsFTAbnormalStr",depdrgsFTAbnormalStr+"作为特异数据未显示在上图中。");
		
						}else{
							remap.put("drgsFTAbnormalStr",depdrgsFTAbnormalStr);
						}
						
						if(Abnormal.lastIndexOf(",")>0){
							AbnormalStr=Abnormal.substring(0, Abnormal.lastIndexOf(","))+"";
							
						}else{
							AbnormalStr=Abnormal+"";
						}
						AbnormalStr = AbnormalStr.replaceAll("\\s*", "");// 去除空格
						paramMap.put("AbnormalStr", AbnormalStr );
						
						
					}else{
						remap.put("drgsFTAbnormalStr",depdrgsFTAbnormalStr);
						paramMap.put("AbnormalStr",AbnormalStr);
					}
					for (Map<String, Object> map : findchart15mapList) {
						Double chart15_fee = MonitorResultUtil.objectToDouble(String.valueOf(map.get("chart15_fee") == null ? 0 : map.get("chart15_fee")));
						Double chart15_time = MonitorResultUtil.objectToDouble(String.valueOf(map.get("chart15_time") == null ? 0 : map.get("chart15_time")));
						if (chart15_fee >1 && chart15_time > 1) {
							depdrgsFT1++;
							depdrgsFeeET1.append(map.get("chart15_drgs")+"-"+map.get("chart15_drgsdesc") + "(" + chart15_time + "," + chart15_fee + ")、");
						} else if (chart15_fee > 1 && chart15_time <= 1) {
							depdrgsFT2++;
							depdrgsFeeET2.append(map.get("chart15_drgs")+"-"+map.get("chart15_drgsdesc") + "(" + chart15_time + "," + chart15_fee + ")、");
						} else if (chart15_fee <= 1 && chart15_time <= 1) {
							depdrgsFT3++;
							depdrgsFeeET3.append(map.get("chart15_drgs")+"-"+map.get("chart15_drgsdesc") + "(" + chart15_time + "," + chart15_fee + ")、");
						} else if (chart15_fee <=1 && chart15_time > 1) {
							depdrgsFT4++;
							depdrgsFeeET4.append(map.get("chart15_drgs")+"-"+map.get("chart15_drgsdesc") + "(" + chart15_time + "," + chart15_fee + ")、");
						}

					}
			
					if (depdrgsFeeET1.lastIndexOf("、") > 0) {
						depdrgsFeeET1Str=depdrgsFeeET1.substring(0, depdrgsFeeET1.lastIndexOf("、"));
					}
					if (depdrgsFeeET2.lastIndexOf("、") > 0) {
						depdrgsFeeET2Str=depdrgsFeeET2.substring(0, depdrgsFeeET2.lastIndexOf("、"));
					}
					if (depdrgsFeeET4.lastIndexOf("、") > 0) {
						depdrgsFeeET4Str=depdrgsFeeET4.substring(0, depdrgsFeeET4.lastIndexOf("、"));
					}
					if (depdrgsFeeET3.lastIndexOf("、") > 0) {
						depdrgsFeeET3Str=depdrgsFeeET3.substring(0, depdrgsFeeET3.lastIndexOf("、"));
					}
					int gt1drgsdeptime = depdrgsFT1+depdrgsFT4;//时间大于1的个数
					int gt1drgsdepfee  = depdrgsFT2+depdrgsFT1;//费率大于1的个数
					remap.put("gt1drgsdeptime", gt1drgsdeptime);
					remap.put("gt1drgsdepfee", gt1drgsdepfee);
					
					remap.put("depdrgsFT1", depdrgsFT1);
					remap.put("depdrgsFT2", depdrgsFT2);
					remap.put("depdrgsFT3", depdrgsFT3);
					remap.put("depdrgsFT4", depdrgsFT4);
					
					remap.put("depdrgsFeeET1Str", depdrgsFeeET1Str);
					remap.put("depdrgsFeeET2Str", depdrgsFeeET2Str);
					remap.put("depdrgsFeeET3Str", depdrgsFeeET3Str);
					remap.put("depdrgsFeeET4Str", depdrgsFeeET4Str);
					remap.put("findchart15mapList", findchart15mapList);
					//重点24个DRG时间消耗指数大于1，时间消耗指数值排名前五位的DRGs病组
					List<Object[]> findcharttimetop5 = wordReportFacade.findcharttimetop5(paramMap);
					List<Map<String, Object>> findcharttimetop5mapList = new ArrayList<Map<String, Object>>();
					if(!findcharttimetop5.isEmpty()){
						int i=1;
						for(Object[] obj:findcharttimetop5){
							Map<String, Object> map = new HashMap<String, Object>();
							StringBuffer charttimetop5=new StringBuffer();
							if(i<=5)
							{
								if(i<=4){
									charttimetop5.append(obj[0]+"-"+obj[1]+"("+obj[2]+")"+"、");
								map.put("charttimetop5", charttimetop5);
								findcharttimetop5mapList.add(map);}
								else{
									charttimetop5.append(obj[0]+"-"+obj[1]+"("+obj[2]+")"+"。");
									map.put("charttimetop5", charttimetop5);
									findcharttimetop5mapList.add(map);
								}
							}
							i++;
						}
					}
					remap.put("findcharttimetop5mapList", findcharttimetop5mapList);
					//重点24个DRG费用消耗指数大于1，时费用消耗指数值排名前五位的DRGs病组
					List<Object[]> findchartfeetop5 = wordReportFacade.findchartfeetop5(paramMap);
					List<Map<String, Object>> findchartfeetop5mapList = new ArrayList<Map<String, Object>>();
					if(!findchartfeetop5.isEmpty()){
						int i=1;
						for(Object[] obj:findchartfeetop5){
							Map<String, Object> map = new HashMap<String, Object>();
							StringBuffer chartfeetop5=new StringBuffer();
							if(i<=5)
							{
								if(i<=4){
									chartfeetop5.append(obj[0]+"-"+obj[1]+"("+obj[2]+")"+"、");
								map.put("chartfeetop5", chartfeetop5);
								findchartfeetop5mapList.add(map);}
								else{
									chartfeetop5.append(obj[0]+"-"+obj[1]+"("+obj[2]+")"+"。");
									map.put("chartfeetop5", chartfeetop5);
									findchartfeetop5mapList.add(map);
								}
							}
							i++;
						}
					}
					remap.put("findchartfeetop5mapList", findchartfeetop5mapList);
					
					//biaogan67  (次均费用标杆,住院日标杆)
					List<Object[]> findtable67 = wordReportFacade.findtable67(paramMap);
					List<Map<String, Object>> findtable67mapList = new ArrayList<Map<String, Object>>();
					if(!findtable67.isEmpty()){
						int i=1;
						for(Object[] obj:findtable67){
							Map<String, Object> map = new HashMap<String, Object>();
							
							//biaogan67  (次均费用标杆,住院日标杆)
							double biaogan67_1=0;
							double biaogan67_2=0;
								map.put("order", i);
								map.put("table67_1", obj[0]+"");
								map.put("table67_2", obj[1]+"");
								map.put("table67_3", obj[2]+"");
								map.put("table67_4", obj[3]+"");
								map.put("table67_5", obj[4]+"");
								map.put("table67_6", biaogan67_1);
								map.put("table67_7", obj[5]+"");
								map.put("table67_8", biaogan67_2);
								findtable67mapList.add(map);	
							i++;
						}
					}
					remap.put("findtable67mapList", findtable67mapList);
					
					List<Object[]> findtable68 = wordReportFacade.findtable68(paramMap);
					List<Map<String, Object>> findtable68mapList = new ArrayList<Map<String, Object>>();
					if(!findtable68.isEmpty()){
						int i=1;
						for(Object[] obj:findtable68){
							Map<String, Object> map = new HashMap<String, Object>();
								map.put("order", i);
								map.put("table68_1", obj[0]+"");
								map.put("table68_2", obj[1]+"");
								map.put("table68_3", obj[2]+"");
								map.put("table68_4", obj[3]+"");
								map.put("table68_5", obj[4]+"");
								map.put("table68_6", obj[5]+"");
								
								findtable68mapList.add(map);	
							i++;
						}
					}
					remap.put("findtable68mapList", findtable68mapList);
					//************************第七章开始*****************************
				String dephospcode=dto.getDephospcode();//重点病种
                dephospcode = dephospcode.replaceAll("\\s*", "");// 去除空格
				 String dephospcodeStr="";
				if (dephospcode.length() > 7) {
						String[] dephospcodeArry = dephospcode.split("\\|\\|");
						System.out.println(dephospcodeArry.length);
							StringBuffer mdcs2 = new StringBuffer();
							if(dephospcodeArry.length>1){
							for (int o = 0; o < dephospcodeArry.length; o++) {
								mdcs2.append("'" + dephospcodeArry[o] + "'"+",");
							}
							}
							else{
								dephospcodeStr="'" + dephospcode + "'";
							}
							if(mdcs2.lastIndexOf(",")>0){
								dephospcodeStr=mdcs2.substring(0, mdcs2.lastIndexOf(","))+"";
							}
						
					} else {
						dephospcodeStr="'" + dephospcode + "'";
					}
				paramMap.put("dephospcodeStr",dephospcodeStr);
				remap.put("dephospcode", dephospcode);	
				
				
				
				List<Object[]> finddiagnose7_1 = wordReportFacade.finddiagnose7_1(paramMap);
				if(!finddiagnose7_1.isEmpty()){
					
					for(Object[] obj:finddiagnose7_1){
						remap.put("finddiagnose7_11", obj[0] == null ? 0 :obj[0]);//出院病历
						remap.put("finddiagnose7_12", obj[1] == null ? 0 :obj[1]);//比例（%）
						remap.put("finddiagnose7_13", obj[2] == null ? 0 :obj[2]);//入组病例
						remap.put("finddiagnose7_14",  obj[3] == null ? 0 :obj[3]);//未入组病例
						remap.put("finddiagnose7_15",  obj[4] == null ? 0 :obj[4]);//大于60天病例
						remap.put("finddiagnose7_16",  obj[5] == null ? 0 :obj[5]);//入组率
					    }
					}else{
						remap.put("finddiagnose7_11", "--");//出院病历
						remap.put("finddiagnose7_12", "--");//比例（%）
						remap.put("finddiagnose7_13", "--");//入组病例
						remap.put("finddiagnose7_14",  "--");//未入组病例
						remap.put("finddiagnose7_15",  "--");//大于60天病例
						remap.put("finddiagnose7_16", "--");//入组率
					}
					
					List<Object[]> findtable89 = wordReportFacade.findtable89(paramMap);
					List<Map<String, Object>> findtable89mapList = new ArrayList<Map<String, Object>>();
					if(!findtable89.isEmpty()){
						int i=1;
						for(Object[] obj:findtable89){
							Map<String, Object> map = new HashMap<String, Object>();
								map.put("order", i);
								map.put("table89_1", obj[0]+"");
								map.put("table89_2", obj[1]+"");
								map.put("table89_3", obj[2]+"");
								map.put("table89_4", obj[3]+"");
								map.put("table89_5", obj[4]+"");
								map.put("table89_6", "--");//药占比
								map.put("table89_7", obj[5]+"");
								map.put("table89_8", obj[6]+"");
								findtable89mapList.add(map);	
								if(i==1){
									remap.put("top1_table89_1", obj[0]+"");//出院最多的科室
									remap.put("top1_table89_2", obj[1]+"");//病例数
									remap.put("top1_table89_3", obj[2]+"");//占比
									
								}
							i++;
						}
					}
					remap.put("findtable89mapList", findtable89mapList);	
					
					List<Object[]> finddiagnose7_4 = wordReportFacade.finddiagnose7_4(paramMap);
					if(!finddiagnose7_4.isEmpty()){
						for(Object[] obj:finddiagnose7_4){
						remap.put("finddiagnose7_41", obj[0] == null ? 0 :obj[0]);//入组病例数最多
						remap.put("finddiagnose7_42", obj[1] == null ? 0 :obj[1]);//技术难度和复杂程度最高
						remap.put("finddiagnose7_43", obj[2] == null ? 0 :obj[2]);//总产出最高
						remap.put("finddiagnose7_44",  obj[3] == null ? 0 :obj[3]);//时间消耗指数最高
						remap.put("finddiagnose7_45",  obj[4] == null ? 0 :obj[4]);//
						}
					}else{
						remap.put("finddiagnose7_41", "--");
						remap.put("finddiagnose7_42", "--");
						remap.put("finddiagnose7_43", "--");
						remap.put("finddiagnose7_44",  "--");
						remap.put("finddiagnose7_45",  "--");
					}
					
					List<Object[]> finddiagnose7_2 = wordReportFacade.finddiagnose7_2(paramMap);
					if(!finddiagnose7_2.isEmpty()){
						for(Object[] obj:finddiagnose7_2){
						remap.put("keshicnt", obj[0] == null ? 0 :obj[0]);//科室数
						remap.put("finddiagnose7_21", obj[1] == null ? 0 :obj[0]);
						remap.put("finddiagnose7_22", obj[2] == null ? 0 :obj[1]);
						remap.put("finddiagnose7_23", obj[3] == null ? 0 :obj[2]);
						remap.put("finddiagnose7_24",  obj[4] == null ? 0 :obj[3]);
						remap.put("finddiagnose7_25",  "--");
						remap.put("finddiagnose7_26",  obj[5] == null ? 0 :obj[4]);
						remap.put("finddiagnose7_27",  obj[6] == null ? 0 :obj[5]);
				     		}
						}else{
						remap.put("keshicnt", "--");//科室数
						remap.put("finddiagnose7_21", "--");
						remap.put("finddiagnose7_22", "--");
						remap.put("finddiagnose7_23", "--");
						remap.put("finddiagnose7_24",  "--");
						remap.put("finddiagnose7_25",  "--");
						remap.put("finddiagnose7_26",  "--");
						remap.put("finddiagnose7_27",  "--");
					}
					
					List<Object[]> findtable90 = wordReportFacade.findtable90(paramMap);
					List<Map<String, Object>> findtable90mapList = new ArrayList<Map<String, Object>>();
					if(!findtable90.isEmpty()){
						int i=1;
						for(Object[] obj:findtable90){
							Map<String, Object> map = new HashMap<String, Object>();
								
								map.put("table90_1", obj[0]+"");
								map.put("table90_2", obj[1]+"");
								map.put("table90_3", obj[2]+"");
								map.put("table90_4", obj[3]+"");
								map.put("table90_5", obj[4]+"");
								map.put("table90_6",  obj[5]+"");
								map.put("table90_7", obj[6]+"");
								map.put("table90_8", obj[7]+"");
								map.put("table90_9", obj[8]+"");
								findtable90mapList.add(map);	
							i++;
						}
					}
					remap.put("findtable90mapList", findtable90mapList);	
					List<Object[]> finddiagnose7_3 = wordReportFacade.finddiagnose7_3(paramMap);
					if(!finddiagnose7_3.isEmpty()){
						for(Object[] obj:finddiagnose7_3){
						remap.put("finddiagnose7_31", obj[0] == null ? 0 :obj[0]);
						remap.put("finddiagnose7_32", obj[1] == null ? 0 :obj[1]);
						remap.put("finddiagnose7_33", obj[2] == null ? 0 :obj[2]);
						remap.put("finddiagnose7_34", obj[3] == null ? 0 :obj[3]);
						remap.put("finddiagnose7_35", obj[4] == null ? 0 :obj[4]);
						remap.put("finddiagnose7_36", obj[5] == null ? 0 :obj[4]);
						remap.put("finddiagnose7_37", obj[6] == null ? 0 :obj[5]);
						remap.put("finddiagnose7_38", obj[7] == null ? 0 :obj[5]);
						}
				  }else{
						remap.put("finddiagnose7_31", "--");
						remap.put("finddiagnose7_32", "--");
						remap.put("finddiagnose7_33", "--");
						remap.put("finddiagnose7_34",  "--");
						remap.put("finddiagnose7_35",  "--");
						remap.put("finddiagnose7_36",  "--");
						remap.put("finddiagnose7_37",  "--");
						remap.put("finddiagnose7_38",  "--");
					}
					
					List<Object[]> findtable91 = wordReportFacade.findtable91(paramMap);
					List<Map<String, Object>> findtable91mapList = new ArrayList<Map<String, Object>>();
					int binglicnt91=0;
					if(!findtable91.isEmpty()){
						int i=1;
						for(Object[] obj:findtable91){
							Map<String, Object> map = new HashMap<String, Object>();
							if(i<=10){
							    map.put("order",i);
								map.put("table91_1", obj[0]+"");
								map.put("table91_2", obj[1]+"");
								map.put("table91_3", obj[2]+"");
								map.put("table91_4", obj[3]+"");
								map.put("table91_5", obj[4]+"");
								map.put("table91_6",  "--");
								map.put("table91_7", obj[5]+"");
								findtable91mapList.add(map);
								binglicnt91+=Integer.valueOf(obj[2]+"");
								if(i==1){
									remap.put("top1table91_1",obj[0]+"");
									remap.put("top1table91_2",obj[1]+"");
									remap.put("top1table91_3",obj[2]+"");
									remap.put("top1table91_4",obj[3]+"");
									
								}
								}	
							i++;
						}
						remap.put("zushu91", i);//分布在i个DRGs病组下
					}
					remap.put("binglicnt91", binglicnt91);//该病种binglicnt91例DRGs入组病例
					
					remap.put("findtable91mapList", findtable91mapList);	
					
					List<Object[]> findtable92 = wordReportFacade.findtable92(paramMap);
					List<Map<String, Object>> findtable92mapList = new ArrayList<Map<String, Object>>();
					if(!findtable92.isEmpty()){
						int i=1;
						for(Object[] obj:findtable92){
							Map<String, Object> map = new HashMap<String, Object>();
								if(i<=5){
								map.put("table92_1", obj[0]+"");
								map.put("table92_2", obj[1]+"");
								map.put("table92_3", obj[2]+"");
								map.put("table92_4", "--");
								map.put("table92_5", obj[3]+"");
								map.put("table92_6",  obj[4]+"");
								map.put("table92_7","--");
								map.put("table92_8", obj[5]+"");
								findtable92mapList.add(map);}
							i++;
						}
					}
					remap.put("findtable92mapList", findtable92mapList);	
					
					
					
					//************************第八章开始*****************************
					//获取重点MDC
					String mdcCode = dto.getMdcCode();
					mdcCode = mdcCode.replaceAll("\\s*", "");// 去除空格
				 String mdccodeStr="";
				if (mdcCode.length() > 4) {
						String[] mdc = mdcCode.split("\\|\\|");
						if (mdc.length > 1) {
							StringBuffer mdcs = new StringBuffer();
							for (int x = 0; x < mdc.length; x++) {
								mdcs.append("'" + mdc[x] + "',");
							}
							if(mdcs.length()>0){
								mdccodeStr=mdcs.substring(0, mdcs.lastIndexOf(","))+"";
							}
						}
					} else {
						mdccodeStr="'" + mdcCode + "'";
					}
				paramMap.put("mdcCode",mdccodeStr);
				List<Object[]>  mdcdescList = wordReportFacade.findMdcDesc(paramMap);
				String mdcStr="";
				if(mdcdescList.size()>1){
					for(Object[] obj:mdcdescList){
						mdcStr+=obj[0]+"("+obj[1]+")、";
					}
				}else{
					if(!mdcdescList.isEmpty()){
						for(Object[] obj:mdcdescList){
							mdcStr+=obj[0]+"("+obj[1]+")";
						}
					}
				}
				remap.put("mdcStr", mdcStr);
				int  mdcCaseCnt = wordReportFacade.findMdcCaseCnt(paramMap);
				remap.put("mdcCaseCntByCode", mdcCaseCnt);
				remap.put("mdcCaseCntByCodeRatio", imputedRatio(MonitorResultUtil.objectToDouble(mdcCaseCnt),MonitorResultUtil.objectToDouble(remap.get("hospoutcasecnt")+"")));
				int  mdcDRGsCnt = wordReportFacade.findMdcDRGsCnt(paramMap);
				int  mdcDRGsRealCnt = wordReportFacade.findMdcDRGsRealCnt(paramMap);
				remap.put("mdcDRGsCnt", mdcDRGsCnt);
				remap.put("mdcDRGsRealCnt", mdcDRGsRealCnt);
				remap.put("mdcDrgsCntByCodeRatio", imputedRatio(MonitorResultUtil.objectToDouble(mdcDRGsCnt),MonitorResultUtil.objectToDouble(mdcDRGsRealCnt)));
				paramMap.put("mdcCasecnt", mdcCaseCnt);
				List<Map<String,Object>>  mdcdrgtop10MapList = wordReportFacade.findmdcDdrgtop10MapList(paramMap);	
				remap.put("mdcdrgtop10MapList", mdcdrgtop10MapList);
				int mdcdrgcasetop10=0;
				for(Map<String,Object> map:mdcdrgtop10MapList){
					int cnt=Integer.valueOf(map.get("outcase")+"");
					mdcdrgcasetop10+=cnt;
				}
				remap.put("mdcdrgcasetop10",mdcdrgcasetop10);
				remap.put("mdcDrgsCaseRatio", imputedRatio(MonitorResultUtil.objectToDouble(mdcdrgcasetop10),MonitorResultUtil.objectToDouble(mdcCaseCnt)));
				List<Map<String,Object>>  mdcdrgweighttop10MapList = wordReportFacade.findmdcdrgweighttop10List(paramMap);
				double mdcdrgweighttop10=0;
				double mdctotalweight=0;
				for(Map<String,Object> map:mdcdrgweighttop10MapList){
					mdctotalweight=MonitorResultUtil.objectToDouble(map.get("mdctotalweight")+"");
					double weight=MonitorResultUtil.objectToDouble(map.get("weight")+"");
					mdcdrgweighttop10+=weight;
				}
				remap.put("mdcdrgweighttop10", mdcdrgweighttop10);
				remap.put("mdcDrgsWeightRatio", imputedRatio(MonitorResultUtil.objectToDouble(mdcdrgweighttop10),MonitorResultUtil.objectToDouble(mdctotalweight)));
				remap.put("mdcdrgweighttop10MapList", mdcdrgweighttop10MapList);
				//***********************************第九章开始*************************************************************
				// 获取未入组原因
				List<Object[]> notInGroupReasonList = wordReportFacade.findNotInGroupReason(paramMap);
				int reason1=0;
				int reason2=0;
				int reason3=0;
				int reason4=0;
				int reason5=0;
				int reason6=0;
				if(!notInGroupReasonList.isEmpty()){
					for(Object[] obj:notInGroupReasonList){
						if (MonitorResultUtil.objectToDouble(obj[0] == null ? "0" : obj[0] == null ? "0" : obj[0].toString()).intValue() == 1) {
							reason1 = MonitorResultUtil.objectToDouble(obj[1] == null ? "0" : obj[1].toString()).intValue();
						} else if (MonitorResultUtil.objectToDouble(obj[0] == null ? "0" : obj[0].toString()).intValue() == 2) {
							reason2 = MonitorResultUtil.objectToDouble(obj[1] == null ? "0" : obj[1].toString()).intValue();
						} else if (MonitorResultUtil.objectToDouble(obj[0] == null ? "0" : obj[0].toString()).intValue() == 3) {
							reason3 = MonitorResultUtil.objectToDouble(obj[1] == null ? "0" : obj[1].toString()).intValue();
						} else if (MonitorResultUtil.objectToDouble(obj[0] == null ? "0" : obj[0].toString()).intValue() == 4) {
							reason4 = MonitorResultUtil.objectToDouble(obj[1] == null ? "0" : obj[1].toString()).intValue();
						} else if (MonitorResultUtil.objectToDouble(obj[0] == null ? "0" : obj[0].toString()).intValue() == 5) {
							reason5 = MonitorResultUtil.objectToDouble(obj[1] == null ? "0" : obj[1].toString()).intValue();
						} else if (MonitorResultUtil.objectToDouble(obj[0] == null ? "0" : obj[0].toString()).intValue() == 6) {
							reason6 = MonitorResultUtil.objectToDouble(obj[1] == null ? "0" : obj[1].toString()).intValue();
						}
					}
				}
				remap.put("reason1", reason1);
				remap.put("reason2", reason2);
				remap.put("reason3", reason3);
				remap.put("reason4", reason4);
				remap.put("reason5", reason5);
				remap.put("reason6", reason6);

				// 大于60天的病例科室分布
				List<Object[]> depOver60List = wordReportFacade.findDepOver60List(paramMap);
				List<Map<String, Object>> depOver60MapList = new ArrayList<Map<String, Object>>();
				if (depOver60List.size() > 0) {
					int i=1;
					for (Object[] obj : depOver60List) {
						Map<String, Object> map = new HashMap<String, Object>();
						map.put("order", i);
						map.put("depname", obj[0]);
						map.put("casecnt", obj[1]);
						map.put("casecntRatio", Arith.mul(Arith.div(MonitorResultUtil.objectToDouble(obj[1] == null ? "0" : obj[1]+""), MonitorResultUtil.objectToDouble(remap.get("over60casecnt")+""), 4), 100));
						depOver60MapList.add(map);
						i++;
					}
				}
				remap.put("depOver60MapList", depOver60MapList);
		
				 //未入组病例科室分布
				List<Map<String, Object>> notInGroupCaseByDepMapList = new ArrayList<Map<String, Object>>();
				List<Object[]> notInGroupCaseByDepList = wordReportFacade.findNotInGroupCaseByDepList(paramMap);
				if (notInGroupCaseByDepList.size() > 0) {
					int i=1;
					for (Object[] obj : notInGroupCaseByDepList) {
						Map<String, Object> map = new HashMap<String, Object>();
						map.put("order", i);
						map.put("depname", obj[0]+"");
						map.put("casecnt", obj[1]);
						map.put("casecntRatio", Arith.mul(Arith.div(MonitorResultUtil.objectToDouble(obj[1] == null ? "0" : obj[1].toString()), MonitorResultUtil.objectToDouble(remap.get("notingroupcasecnt")+""), 4), 100));
						notInGroupCaseByDepMapList.add(map);
						i++;
					}
				}
				
				remap.put("notInGroupCaseByDepMapList", notInGroupCaseByDepMapList);
				
			    /**
				 * 未入组病例主诊断分布
				 */
				List<Object[]> notInGroupCaseByDiagList = wordReportFacade.findNotInGroupCaseByDiagList(paramMap);
				List<Map<String, Object>> notInGroupCaseByDiagMapList = new ArrayList<Map<String, Object>>();
				if (notInGroupCaseByDiagList.size() > 0) {
					int i=1;
					for (Object[] obj : notInGroupCaseByDiagList) {
						Map<String, Object> map = new HashMap<String, Object>();
						map.put("order",i);
						map.put("code", obj[0]);
						map.put("desc", obj[1]);
						map.put("cnt", obj[2]);
						map.put("ratio", Arith.mul(Arith.div(MonitorResultUtil.objectToDouble(obj[2] == null ? "0" : obj[2]+""), MonitorResultUtil.objectToDouble(remap.get("notingroupcasecnt")+""), 4), 100));
						notInGroupCaseByDiagMapList.add(map);
						i++;
					}
				}
				remap.put("notInGroupCaseByDiagMapList", notInGroupCaseByDiagMapList);
				/**
				 * 未入组病例手术分布
				 */
				List<Object[]> notInGroupCaseByOperList = wordReportFacade.findNotInGroupCaseByOperList(paramMap);
				List<Map<String, Object>> notInGroupCaseByOperMapList = new ArrayList<Map<String, Object>>();
				if (notInGroupCaseByOperList.size() > 0) {
					int i=1;
					for (Object[] obj : notInGroupCaseByOperList) {
						Map<String, Object> map = new HashMap<String, Object>();
						map.put("order", i);
						map.put("code", obj[0]);
						map.put("desc", obj[1]);
						map.put("cnt", obj[2]);
						map.put("ratio", Arith.mul(Arith.div(MonitorResultUtil.objectToDouble(obj[2] == null ? "0" : obj[2]+""), MonitorResultUtil.objectToDouble(remap.get("notingroupcasecnt")+""), 4), 100));
						notInGroupCaseByOperMapList.add(map);
						i++;
					}
				}
				remap.put("notInGroupCaseByOperMapList", notInGroupCaseByOperMapList);
				
				/**
				 * mdc专业drg覆盖率
				 */
				StringBuffer mdcCodetop5 = new StringBuffer();
				List<Object[]> mdcDrgsTop5List = wordReportFacade.findMdcDrgsTop5List(paramMap);
				String mdcCodeLast5 ="--";
				if (mdcDrgsTop5List.size() > 0) {
					for (Object[] obj : mdcDrgsTop5List) {
							mdcCodetop5.append("'" + obj[0] + "',");
					}
				}
				if(mdcCodetop5.length()>0){
					 mdcCodeLast5 = mdcCodetop5.substring(0, mdcCodetop5.lastIndexOf(",")).toString();
				}
				
				// 本院由低到高小于前五的mdc专业下缺失的drg的权重大于1和大于9的
				List<Object[]> mdcDrgsByWeightOver1List = wordReportFacade.findMdcDrgsByWeightOver1List(paramMap, mdcCodeLast5);
                 int mdcweightover1cnt=mdcDrgsByWeightOver1List.size();
                 int overweight9cnt=0;
                 List<Map<String, Object>> mdcDrgsByWeightOver1MapList = new ArrayList<Map<String, Object>>();
                 int mdcDrgsByWeightOver1Cnt = wordReportFacade.findMdcDrgsByWeightOver1Cnt(paramMap, mdcCodeLast5);
                 String mdcweighOver9Str="--";              
				if (mdcDrgsByWeightOver1List.size() > 0) {
					int i=0;
					for (Object[] obj : mdcDrgsByWeightOver1List) {
						Map<String, Object> map = new HashMap<String, Object>();
						map.put("order", i);
						map.put("code", obj[0]);
						map.put("desc", obj[1] + "--" + obj[2]);
						map.put("weight", obj[3]);
						mdcDrgsByWeightOver1MapList.add(map);
						i++;
					}
				}
				List<Object[]> mdcDrgsByWeightOver9List = wordReportFacade.findMdcDrgsByWeightOver9List(paramMap, mdcCodeLast5);
				StringBuffer mdcdesc = new StringBuffer();
				for (Object[] obj : mdcDrgsByWeightOver9List) {	
					  mdcdesc.append(obj[1] + "(" + obj[2] + ")、");  	 
				}
				overweight9cnt=mdcDrgsByWeightOver1List.size();
				if(mdcdesc.length()>0){
					mdcweighOver9Str=mdcdesc.substring(0, mdcdesc.lastIndexOf("、"))+ "";
				}
				
				   remap.put("mdcCodeLast5", mdcCodeLast5);
				   remap.put("mdcweightover1cnt", mdcDrgsByWeightOver1Cnt);
				   remap.put("overweight9cnt", overweight9cnt);
				   remap.put("mdcweighOver9Str", mdcweighOver9Str);
				   remap.put("mdcDrgsByWeightOver1MapList", mdcDrgsByWeightOver1MapList);
				   
					// 病组的时间消耗指数
					List<Object[]> drgsTimeList = wordReportFacade.findDrgsTimeList(paramMap);
					int mdctimeThan1= drgsTimeList.size();
					double mdctimeThan1ratio=Arith.mul(Arith.div(MonitorResultUtil.objectToDouble(drgsTimeList.size()), MonitorResultUtil.objectToDouble(remap.get("hospdrgcnt")+""), 4), 100);
					String drgstimestr="--";
					String drgstimecntstr="--";					
					if (drgsTimeList.size() > 0) {
						StringBuffer drgstime = new StringBuffer();
						StringBuffer drgstimecnt = new StringBuffer();
						int index = 0;
						for (Object[] obj : drgsTimeList) {
							if (index < 3) {
								drgstime.append(obj[0] + "(" + obj[1] + ")、");
								drgstimecnt.append(Arith.round(MonitorResultUtil.objectToDouble(obj[2] == null ? "0" : obj[2].toString()), 2) + "、");
							}
							index++;
						}
						if(drgstime.length()>0){
							drgstimestr=drgstime.substring(0, drgstime.lastIndexOf("、")).toString() + "";
						}
						if(drgstimecnt.length()>0){
							drgstimecntstr=drgstimecnt.substring(0, drgstimecnt.lastIndexOf("、")).toString() + "";
						}
					}
					  remap.put("mdctimeThan1", mdctimeThan1);
					  remap.put("mdctimeThan1ratio", mdctimeThan1ratio);
					  remap.put("drgstimestr", drgstimestr);
					  remap.put("drgstimecntstr", drgstimecntstr);
					// DRGS的费用消耗指数
					List<Object[]> drgsFeeList = wordReportFacade.findDrgsFeeList(paramMap);
					int mdcfeeThan1= drgsFeeList.size();
					double mdcfeeThan1ratio=Arith.mul(Arith.div(MonitorResultUtil.objectToDouble(drgsFeeList.size()), MonitorResultUtil.objectToDouble(remap.get("hospdrgcnt")+""), 4), 100);
					String drgsfeestr="--";
					String drgsfeecntstr="--";					
					if (drgsFeeList.size() > 0) {
						StringBuffer drgsfee = new StringBuffer();
						StringBuffer drgsfeecnt = new StringBuffer();
						int index = 0;
						for (Object[] obj : drgsFeeList) {
							if (index < 3) {
								drgsfee.append(obj[0] + "(" + obj[1] + ")、");
								drgsfeecnt.append(Arith.round(MonitorResultUtil.objectToDouble(obj[2] == null ? "0" : obj[2].toString()), 2) + "、");
							}
							index++;
						}
						if(drgsfee.length()>0){
							drgsfeestr=drgsfee.substring(0, drgsfee.lastIndexOf("、")).toString() + "";
						}
						if(drgsfeecnt.length()>0){
							drgsfeecntstr=drgsfeecnt.substring(0, drgsfeecnt.lastIndexOf("、")).toString() + "";
						}
				
					}
					  remap.put("mdcfeeThan1", mdcfeeThan1);
					  remap.put("mdcfeeThan1ratio", mdcfeeThan1ratio);
					  remap.put("drgsfeestr", drgsfeestr);
					  remap.put("drgsfeecntstr", drgsfeecntstr);
					
				} catch (Exception e) {
					e.printStackTrace();
					errMsg=e.getMessage();
					remap.put("errMsg", errMsg);
				}
				return InvokeResult.success(remap);
			}
		} else {
			return InvokeResult.failure("无数据");
		}
	
/*		String a="",b="",c="",d="";
		List<Map<String, Object>> mdclist = wordReportFacade.findmdc();
		for(Map<String, Object> aa:mdclist){
			String mdc=aa.get("mdc")+"";
			Double fee=MonitorResultUtil.objectToDouble(aa.get("fee")+"");
			Double time=MonitorResultUtil.objectToDouble(aa.get("time")+"");
			if (fee >1 && time > 1) {
				a+=mdc+"("+time+","+fee+")、";

			} else if (fee > 1 && time <= 1) {
				b+=mdc+"("+time+","+fee+")、";
			} else if (fee <= 1 && time <= 1) {
				c+=mdc+"("+time+","+fee+")、";
			} else if (fee <=1 && time > 1) {
				d+=mdc+"("+time+","+fee+")、";
			}
		}
		System.out.println("a"+a);
		System.out.println("b"+b);
		System.out.println("c"+c);
		System.out.println("d"+d);
		remap.put("mdcFeeAndTimeEffMapList", mdclist);
		return InvokeResult.success(remap);*/
	}

	@ResponseBody
	@RequestMapping(value = "createWordReport")
	public InvokeResult createWordReport() {
		Map<String,Object> map=new HashMap<String,Object>();
		long start = System.currentTimeMillis();
		long reportNo = System.currentTimeMillis();
		File folder = new File(new File(ResourceLoader.getPath("")).getParentFile().getParent() + "/tmp/");
		if (!folder.exists()) {
			folder.mkdirs();
		}
		String outputFile = folder.getPath() + File.separator + reportNo + ".doc";
		try {
			Configuration configuration = new Configuration();
			configuration.setDefaultEncoding("UTF-8");
			configuration.setClassForTemplateLoading(WordReportController.class, "/config/templates/");
			Template template = configuration.getTemplate("report1.xml");
			FileOutputStream fos = new FileOutputStream(new File(outputFile));
			Writer writer = new OutputStreamWriter(fos);
			template.process(remap, writer);
			writer.close();
			System.err.println(" \n 文档生成成功 path=\n" + outputFile);
			System.err.println("生成文档耗时time=" + (System.currentTimeMillis() - start) / 1000);
			map.put("patch", "tmp/" + reportNo + ".doc");
			map.put("hospname",remap.get("hospname"));
			return InvokeResult.success(map);
		} catch (Exception e) {
			e.printStackTrace();
			return InvokeResult.failure("生成文档失败[" + e.getMessage() + "]");
		}
	}

	/**
	 * @methodname :imputedRatio
	 * @Description : 计算百分比
	 * @author:LiuHongjun
	 * @return Double
	 * @date :2016年9月10日
	 */
	public Double imputedRatio(Double a, Double b) {
		return Arith.mul(Arith.div(a, b, 4), 100);
	}
	/**
	 * @methodname :imputedMiddle
	 * @Description : 计算中位数
	 * @author:LiuHongjun
	 * @return Double
	 * @date :2016年9月11日
	 */
	public Double imputedMiddleWeight(List<Map<String, Object>> list) {
		Double middledata=0.0;
		List<Double> doublelist = new ArrayList<Double>();
		for (Map<String, Object> objlist : list) {
			doublelist.add(MonitorResultUtil.objectToDouble((objlist.get("weight") == null ? 0 :objlist.get("weight")) + ""));
		}
		Collections.sort(doublelist);// 排序科室权重
		if (doublelist.size() % 2 == 0) {
			middledata =Arith.round(Arith.div(doublelist.get((doublelist.size() / 2) - 1) + doublelist.get(doublelist.size() / 2), 2), 2) ;
		} else {
			middledata = Arith.round(doublelist.get(((doublelist.size() +1)/ 2)-1),2);
		}
		return middledata;
	}
	/**
	 * @methodname :imputedMiddle
	 * @Description : 计算中位数
	 * @author:LiuHongjun
	 * @return Double
	 * @date :2016年9月11日
	 */
	public Double imputedMiddleCmi(List<Map<String, Object>> list) {
		Double middledata=0.0;
		List<Double> doublelist = new ArrayList<Double>();
		for (Map<String, Object> objlist : list) {
			doublelist.add(MonitorResultUtil.objectToDouble((objlist.get("cmi") == null ? 0 :objlist.get("cmi")) + ""));
		}
		Collections.sort(doublelist);// 排序科室权重
		if (doublelist.size() % 2 == 0) {
			middledata =Arith.round(Arith.div(doublelist.get((doublelist.size() / 2) - 1) + doublelist.get(doublelist.size() / 2), 2), 2) ;
		} else {
			middledata = Arith.round(doublelist.get(((doublelist.size() +1)/ 2)-1),2);
		}
		return middledata;
	}
	public Double imputedMiddleFee(List<Map<String, Object>> list) {
		Double middledata=0.0;
		List<Double> doublelist = new ArrayList<Double>();
		for (Map<String, Object> objlist : list) {
			doublelist.add(MonitorResultUtil.objectToDouble((objlist.get("feeEff") == null ? 0 :objlist.get("feeEff")) + ""));
		}
		Collections.sort(doublelist);// 排序科室权重
		if (doublelist.size() % 2 == 0) {
			middledata =Arith.round(Arith.div(doublelist.get((doublelist.size() / 2) - 1) + doublelist.get(doublelist.size() / 2), 2), 2) ;
		} else {
			middledata = Arith.round(doublelist.get(((doublelist.size() +1)/ 2)-1),2);
		}
		return middledata;
	}
	public Double imputedMiddleTime(List<Map<String, Object>> list) {
		Double middledata=0.0;
		List<Double> doublelist = new ArrayList<Double>();
		for (Map<String, Object> objlist : list) {
			doublelist.add(MonitorResultUtil.objectToDouble((objlist.get("timeEff") == null ? 0 :objlist.get("timeEff")) + ""));
		}
		Collections.sort(doublelist);// 排序科室权重
		if (doublelist.size() % 2 == 0) {
			middledata =Arith.round(Arith.div(doublelist.get((doublelist.size() / 2) - 1) + doublelist.get(doublelist.size() / 2), 2), 2) ;
		} else {
			middledata = Arith.round(doublelist.get(((doublelist.size() +1)/ 2)-1),2);
		}
		return middledata;//depFeeAndTimeEffMapList remap.get biaogan4
	}
}
